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 / Running code in a text file

Author
Message
Code eater
17
Years of Service
User Offline
Joined: 17th Feb 2008
Location: Behind You!
Posted: 28th Jun 2008 14:07
Hey,,,

Is it possible to write DBC code in a text file and then write a program using DBC to read the text file and run the code in it?

Any response would be appreciated,,

thanks,

codeeater
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 28th Jun 2008 15:32 Edited at: 28th Jun 2008 15:33
Yes, it`s possible.

The code you wan`t to run in the text file has to be in a function.

Then use #include "mycode.txt" in DBC and call the function.

When you build an executable, it will include the code with it, but you can`t add any code later after building it.

TheComet

Oooooops!!! I accidentally formated drive c.
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 28th Jun 2008 15:59
I think I didn`t understand your concept at the start. If you wan`t an exe to run code you write in a txt file, it`s not possible, unless you have something like this in your DBC code:



So you would have to write all the functions in dark basic again.

Oooooops!!! I accidentally formated drive c.
master programmer
20
Years of Service
User Offline
Joined: 30th May 2005
Location: 3D Space
Posted: 29th Jun 2008 09:23
So why couldn't you still use the #include command for this?

BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 29th Jun 2008 09:53 Edited at: 29th Jun 2008 09:54
if you use #include, the text file gets compiled with the rest of the program, and cannot be changed at all making it no more useful than other functions that are included in other files.

@Code eater
It seems like what you want is a darkbasic compiler. As far as I know, it doesn't exist in a standalone format.

Ever notice how in Microsoft word, the word "microsoft" is auto corrected to be "Microsoft" but "macintosh" just gets the dumb red underline?
Code eater
17
Years of Service
User Offline
Joined: 17th Feb 2008
Location: Behind You!
Posted: 29th Jun 2008 11:43
Ok thanks,,, I dont really need it I was just wandering so i could add things to programs really easily.

Thanks

Codeeater
master programmer
20
Years of Service
User Offline
Joined: 30th May 2005
Location: 3D Space
Posted: 30th Jun 2008 00:56
Quote: "if you use #include, the text file gets compiled with the rest of the program, and cannot be changed at all making it no more useful than other functions that are included in other files"


It has become impossible to change the contents of a text file? All you would have to have is a function at the start of the text file that is called some place in the DBC program and whatever is written in the text file would be executed.

Based on what he is asking you can write DBC code into a text file making sure that it has the function and endfunction commands surrounding it. Then, that function is called in DBC. I don't really see how this wouldn't work.

BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 30th Jun 2008 02:30
The text file is compiled INTO the .exe file. So yes, it would run the function in it, but no, it cannot be changed, since the text file no longer exists once you compile it. I thought it would work too, so I tried it and found that TheComet was right:
Quote: "When you build an executable, it will include the code with it, but you can`t add any code later after building it."


Ever notice how in Microsoft word, the word "microsoft" is auto corrected to be "Microsoft" but "macintosh" just gets the dumb red underline?
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 30th Jun 2008 05:58
What you need to do is put info in the text file that the main compiled exe loads and uses to create something - using a generic function as already stated.

That way, as you are not using #Include, the text file will not be compiled with the rest of the program and will remain external.

You can then change the data in the file to affect what the main program generates - without having to compile another exe every time something changes.

TDK_Man

Login to post a reply

Server time is: 2025-06-06 00:12:32
Your offset time is: 2025-06-06 00:12:32