Posts: 1,688
Threads: 119
Joined: Jun 2003
when i attempt to save my map on my map editor as binary, it seems to work. then when i attempt to open it and read it, it seems to work fine until it starts to pull in string variables. it brings in nothing for a string variable then everything after that is crazy. anything i can do?
Jumping Jahoolipers!
Posts: 6,419
Threads: 74
Joined: Mar 2002
You have to use fixed length strings;
Will read LEN(stri$) bytes, if stri$ is empty it will read nothing.
Posts: 3,522
Threads: 189
Joined: Dec 2003
Code:
stri$=SPACE$(32)
GET #1, , stri$
Will read 32 bytes.
Code:
num=16
stri$=SPACE$(num)
GET #1, , stri$
Will read num (16) bytes.
Posts: 3,279
Threads: 170
Joined: Nov 2003
Whenever I need to put variable-length strings into a binary file, I first store the length of the string as an integer value and then the string. Reading it back in is also easy; you have a dynamic string variable set to read the data...you read the size of the string, SPACE the dynamic string variable to the size indicated, then read the string using your dynamic string variable. Works every time.
Code:
DIM stringSize AS INTEGER
stringSize = LEN(outString$)
PUT #fh, , stringSize
PUT #fh, , outString$
...
GET #fh, , stringSize
inString$ = SPACE$(stringSize)
GET #fh, , inString$
I'd knock on wood, but my desk is particle board.
Posts: 1,688
Threads: 119
Joined: Jun 2003
i see... now i get it. thanks!
::EDIT::
it works like a charm! the files are approx. 2.5 times smaller than they were before. thanks!
Jumping Jahoolipers!