Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Writing to and reading from files

Author
Message
Game Master1330
16
Years of Service
User Offline
Joined: 19th Oct 2007
Location: (GetReaderXYZ() * 42 ) / 0
Posted: 13th Apr 2013 04:09
Hey,

I am attempting to store my levels in files, but for some reason they don't load correctly... This is my read and write code:



Matt

Position Object Game Master1330, Object Position X(Reader), Object Position Y(Reader), Object Position Z(Reader) - 5

Hide Object Game Master1330
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 13th Apr 2013 13:20 Edited at: 13th Apr 2013 13:20
Those read / write functions operating on references are a bit fishy.
I think your problem is that you can't read directly to an array like that; rather try storing the values to a temporary local variable first like so:


Also you should probably change the array sizes when loading to ensure that they can hold the MaxTiles amount of tiles just read from the input file.


"Why do programmers get Halloween and Christmas mixed up?"
Game Master1330
16
Years of Service
User Offline
Joined: 19th Oct 2007
Location: (GetReaderXYZ() * 42 ) / 0
Posted: 13th Apr 2013 15:21
Ok thanks, I'll try this and post my results

Position Object Game Master1330, Object Position X(Reader), Object Position Y(Reader), Object Position Z(Reader) - 5

Hide Object Game Master1330
Game Master1330
16
Years of Service
User Offline
Joined: 19th Oct 2007
Location: (GetReaderXYZ() * 42 ) / 0
Posted: 13th Apr 2013 18:46
This didn't work :\ Any other ideas?

Position Object Game Master1330, Object Position X(Reader), Object Position Y(Reader), Object Position Z(Reader) - 5

Hide Object Game Master1330
29 games
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 13th Apr 2013 23:02 Edited at: 13th Apr 2013 23:08
Try deleting the file before you write data to it so add:

if file exist("Test.lvl")
delete file "Test.lvl"
endif

Before the open to write command.

Also, rather than save the data as byte data type try saving them as word data type (and then obviously load them as word data type). According to the help files bytes go between 0 and 255 so this might work.

From the help files:
INTEGER Range : –2,147,483,648 to 2,147,483,647
REAL Range : 3.4E +/- 38 (7 digits)
BOOLEAN Range : 0 to 1
BYTE Range : 0 to 255
WORD Range : 0 to 65535
DWORD Range : 0 to 4,294,967,295
DOUBLE INTEGER Range : –9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
DOUBLE FLOAT Range : 1.7E +/- 308 (15 digits)

So you might want to try integers or dwords or what ever works for you or gives you the smallest file size, which probably won't be an issue.

one of these days I'll come up with a better signature

Login to post a reply

Server time is: 2024-04-20 04:43:35
Your offset time is: 2024-04-20 04:43:35