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 / Commands saved and used by data file

Author
Message
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 31st Dec 2007 23:33 Edited at: 31st Dec 2007 23:34
Hey, guys!

I don`t know if this is a question for TDK or not, but here it is:

I wrote my source code into a data file and I want my final to read this data file and do whatever it says on it.

question 1:How do I do that?
=======================================================
question 2:Is it even possible? Because if I build a final, it wont be able to import and execute the darkbasic code, in fact, it wont understand it at all(my assumption...)
=======================================================

Thank you in advance

Oooooops!!! I accidentally formated drive c.
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 1st Jan 2008 23:03
If I understand you correctly, it is not possible.

When you run the source code in the DB editor it is is interpreted by the 'compiler' - a program called DB.EXE.

When your own programs are compiled into exe's (with Build Final) they do not contain DB.EXE so they have no way to interpret any .DBA source files you supply with it.

Users of your program must have their own copy of DBC installed to use them - and of course it would be illegal for you to distribute DB.EXE with your program.

Instead you must write your own interpreter/parser.

This isn't that difficult - just long-winded and time consuming.

It means you have to load a line of your text file and chop (parse) it into pieces - separating the commands and parameters. Your program would then run the command specified with the correct parameters.

So, if your program loads the line:

Set Display Mode 800,600,32

...it must extract the command used (Set Display Mode), along with the three numeric parameters (placing them in numeric variables) and use them with the command.

Pseudo code:

Open text file
Read String 1,lineofcode$
Scan line for command & parameters - placing into variables Command$, P1, P2 and P3
If Command$="Set Display Mode"
Set Display Mode P1,P2,P3
Endif


It gets time consuming because you have to write the same routines for every one of the commands used in the text files.

TDK_Man

TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 2nd Jan 2008 14:57
Clever but complicated.

But it will work, so I`ll do that.

Thanks TDK_Man

Oooooops!!! I accidentally formated drive c.

Login to post a reply

Server time is: 2025-06-02 09:38:30
Your offset time is: 2025-06-02 09:38:30