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 / executing commands from strings

Author
Message
Sinani201
19
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 19th Aug 2007 19:04
Is it possible to get a command from a string? For instance, if there was a string labeled a$, and was equal to "circle 20,20,7", how could I turn that into a DB command?

Did someone say 3D scanning on my desk, or was that just an AdBot?
What happens when when you mix coke, pop rocks, vinegar, and baking soda?
Kevin Picone
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 19th Aug 2007 19:06
No, you'd have to parse the string manually

Pixelator
18
Years of Service
User Offline
Joined: 8th Jul 2007
Location: here
Posted: 19th Aug 2007 19:41
parse?

(Y=M*X+B)=(X=(Y-B)/M)=(B=Y-M*X)=(M=Y-B/X)
and if you can figure out what it means i will give you a cookie.
TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 19th Aug 2007 19:59
Yes - go through the contents of a$ looking for the command Circle and if you find it, manually extract the 20, 20 and 7 then convert them from strings to numbers to use with the Circle command.

TDK_Man

Sinani201
19
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 19th Aug 2007 21:24
erm... is there another way to do it?

Did someone say 3D scanning on my desk, or was that just an AdBot?
What happens when when you mix coke, pop rocks, vinegar, and baking soda?
Zotoaster
21
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 19th Aug 2007 21:35
Maybe if you got Lua to work with DBC you could to it.

"It's like floating a boat on a liquid that I don't know, but I'm quite happy to drink it if I'm thirsty enough" - Me being a good programmer but sucking at computers
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 20th Aug 2007 03:18
Could you save the strings into a .dba file and then execute the file?

Your signature has been erased by a mod because it was rubbish.
Sinani201
19
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 20th Aug 2007 06:38
not a bad idea...

Did someone say 3D scanning on my desk, or was that just an AdBot?
What happens when when you mix coke, pop rocks, vinegar, and baking soda?
pcRaider
19
Years of Service
User Offline
Joined: 30th May 2007
Location:
Posted: 20th Aug 2007 07:21
What kind of program do you want to be concrete?
What kind of conclusion do you expect?

Do you want to convert it into a figure from a picture?
Do you want to make artificial intelligence?
Most are possible in DarkBasic.
empty
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 20th Aug 2007 13:51
Quote: "Could you save the strings into a .dba file and then execute the file?"

No. When you compile a program in DBC it is converted to "byte code". That means (in simple words) that each command and function is converted to a number that represents it. That way it doesn't need to parse the entire source code each time you execute the program but only once during the compilation process.
A good example for source code execution would be Java Script, which is parsed and executed by the browser when ever you load a page that contains the script.

Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 20th Aug 2007 20:32
@empty
I meant opening the file in DB editor and then compiling and running it, would that still not work?

Your signature has been erased by a mod because it was rubbish.
Pixelator
18
Years of Service
User Offline
Joined: 8th Jul 2007
Location: here
Posted: 20th Aug 2007 21:34


I made a cool printing thingy. Give it a try buy it is hard to figure out unless you read the instructions.

(Y=M*X+B)=(X=(Y-B)/M)=(B=Y-M*X)=(M=Y-B/X)
and if you can figure out what it means i will give you a cookie.
empty
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 20th Aug 2007 21:43
Quote: "@empty
I meant opening the file in DB editor and then compiling and running it, would that still not work?"

Yes, but I assumed Sinani201 wanted to do that during runtime without the compiler.

Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 21st Aug 2007 00:28
could you open db in runtime and compile and run the program without the user knowing?

Your signature has been erased by a mod because it was rubbish.
empty
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 21st Aug 2007 00:32
You could... but you're not allowed to distribute the compiler!

luke810
19
Years of Service
User Offline
Joined: 4th Sep 2006
Location: United States
Posted: 21st Aug 2007 01:36
Quote: "You could... but you're not allowed to distribute the compiler!"


That's not a problem though if hes intending it to be an application or something that you would use with DarkBASIC. He hasn't said anything that would suggest he isn't.
Arkheii
23
Years of Service
User Offline
Joined: 15th Jun 2003
Location: QC, Philippines
Posted: 27th Aug 2007 16:13 Edited at: 27th Aug 2007 16:14
Quote: "could you open db in runtime and compile and run the program without the user knowing?"


You can use the 'Execute File' command to run a new instance of the DBC interpreter and pass a .dba file as a commandline parameter, but it won't be executing the commands within the same instance of DB if that's what you're asking. And like they said, the target computer needs a copy of DBC installed, and you'd still need some way of telling where DBC was installed (or add the DBC directory to the %PATH% environment variable).

Login to post a reply

Server time is: 2026-07-06 01:18:30
Your offset time is: 2026-07-06 01:18:30