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.

DarkBASIC Discussion / About getting rid off that empty row in a created file

Author
Message
Stora tomtefar
20
Years of Service
User Offline
Joined: 15th Mar 2005
Location: Göteborg, Sweden
Posted: 5th Feb 2006 13:28
Hellu.

Well, I'm working on this level-editor, and I've coded the program so when you're making a small tile, the URL to the object, the object number, its X and Z position are stored in strings in an extern .str file. Kinda like this:

ObjectURL$
Objectnumber$
ObjectpositionX$
ObjectpositionZ$

However, since I'm using the "Write to file"-command, an empty row always exist at the end of the file which is causing my main problem: it reads this empty row as a URL to an object it should load, but can't find it and is therefor returning the messege "Object doesn't exist".
Is there any way to remove this empty row inside the level-editor instead of manually removing by opening the file in notepads?

Thanks!

"Even though I'm ugly, I'm extreamly sexy!"
Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 5th Feb 2006 16:40 Edited at: 5th Feb 2006 16:40
You write something to the end of the file that isn't going to be used in your main data. Then when you read that back you end reading the rest of the data.

UFO
19
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 5th Feb 2006 22:14
Yes. You should write "END" after you have written everything, and then you should make it read from the file. Before using it, check if it is "END" or not, and if it is not, use the variable in the game for the objects, but if it is, end the loading process.


Hippopotomonstrosesquippedaliophobia-Fear of long words
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 6th Feb 2006 02:47
It's better to just put all that data in an array and use the "save array" and "load array" commands. Which will put the data in the array instantly and you don't have to worry about all those little annoyances (like deleting the file before writing).

Am I the mascot of save/load array or what?




Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 6th Feb 2006 09:41 Edited at: 6th Feb 2006 09:43
Yes. I didn't know that DB Classic had that command. I thought it was DBPro, but it does.

Login to post a reply

Server time is: 2025-05-23 12:56:07
Your offset time is: 2025-05-23 12:56:07