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 Professional Discussion / remarks within files

Author
Message
Rwilson
23
Years of Service
User Offline
Joined: 19th May 2003
Location: United States
Posted: 15th Oct 2003 07:39
Basically, I plan on allowing some form of modibility in my game. Within the files, I am wishing to put some basic notes on what does what, so that it may be on hand when modding. Is there a simple method, such as putting a apostrophe before a line, to cause DBPro to skip that line when reading a file? I realize that one could create a routine with Left$() and Right$(), but if there's a simpler method, why bother?

Usermlsra - Causing Havoc with a Smile
mimesis
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Norway
Posted: 15th Oct 2003 08:09 Edited at: 15th Oct 2003 08:21
you can use (rem) or the short version (`)

example

rem your description

or

` your description

Edit:
If FileIO is what your thinking then it's another matter.
It should be easy to skip any string you wish in the file dbp is
reading.

example.

read string 1,data$
if left$(data$,3) = "rem"
skip this string
else
extract data from string
endif

Me, You, DBP and everything else, were made in the same place. The Stars!
I wonder what kind of matter DBP bugs are made of ... antimatter ??
Rwilson
23
Years of Service
User Offline
Joined: 19th May 2003
Location: United States
Posted: 15th Oct 2003 08:21 Edited at: 15th Oct 2003 08:21
Yes, I know you can do this within DarkBasic Code, But I am refering to entirely seperate files from the code. I am referring to seperate files, like a "unitdata.dat" or "configfile.ini" or something of that nature. Just to give a small example, assume all one has to do is a ' to remark a line

' The next three lines are unit data 1
The Tank!
500
20
' The next three lines are unit data 2
The Helicopter!
300
14
' This number changes the turn max
500
' etc
etc

Do you get the Idea?

Usermlsra - Causing Havoc with a Smile
mimesis
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Norway
Posted: 15th Oct 2003 08:32
yepp, I edited my post

Me, You, DBP and everything else, were made in the same place. The Stars!
I wonder what kind of matter DBP bugs are made of ... antimatter ??
mimesis
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Norway
Posted: 15th Oct 2003 08:41
... and nope, I cant think of any simpler method to do this without left$().

It isnt that much harder to use left$() to do this

Your example would be read like:

read data$
if left$(data$,1) = "'"
...skip remark
else
...read gamedata$
endif

Me, You, DBP and everything else, were made in the same place. The Stars!
I wonder what kind of matter DBP bugs are made of ... antimatter ??
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 15th Oct 2003 15:28
That's fairly easy ... just a bit of string manipulation

orv
22
Years of Service
User Offline
Joined: 9th Sep 2003
Location: Chicago, IL
Posted: 15th Oct 2003 15:49
i was going to recommend using Trim$() before checking, that way you would just have to check the first character afterwards.

but i don't see a Trim$() function in DBPro. No Trim$() function???

That seems to me to be a pretty basic BASIC command!

If you aim at nothing you'll hit it every time. 806mhz AMD Athlon Processor. 384MB memory.
Windows XP Home Edition. RADEON 9700 Pro graphics card. - editor.exe=1.0.6.1
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 15th Oct 2003 16:29
You can either download my utility DLL, or write your own - it's not too difficult
Rwilson
23
Years of Service
User Offline
Joined: 19th May 2003
Location: United States
Posted: 15th Oct 2003 17:56
Thanks all! Despite the fact that I'll still have to use left$(), your examples have given me a pretty good clue as to how to implement it.

Usermlsra - Causing Havoc with a Smile
BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 15th Oct 2003 19:34
I have a snippet I added to the codebase that does exactly what you want. Not as fancy as the Dlls available, but easy to understand, and works just like the good old ini files of the Win 3.1 days.

http://darkbasic.thegamecreators.com/?m=codebase_view&i=83c96ad254333bb13782657d45a24e23

BatVink (formerly StevieVee)
http://facepaint.me.uk/catalog/default.php
David T
Retired Moderator
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 15th Oct 2003 19:53 Edited at: 15th Oct 2003 19:53
You could make a function to do the work for you, so your code is as easy to read as possible:



Just a little example, don't know if it'll work. It should though.

Fishie says:
"Those who fail to prepare prepare to fail"
"Rule are for the guidance of the wise and the blind obdeniency of the fools"

Login to post a reply

Server time is: 2026-07-28 07:09:06
Your offset time is: 2026-07-28 07:09:06