Qbasicnews.com

Full Version: REQ: Stored command execution
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Would it be possible to have a command that treats the string in the variable passed to it as if it were a command in the actual program?

e.g
blah$ = "SYSTEM"
EXECUTE blah$

would do the same as

SYSTEM


I've wanted a command like that in QB for ages. Are there any plans to put it in FB? (I'll kick myself if it's in the keywords text file...)
Not possible. The compiler should embed a whole interpreter to the RTLib. Note that the string could be a variable, hence you can't know what to execute at compile time.
If you want something like that then you need to work in LISP.
Or use machine code.
Which a compiler does...
Actually... I was wondering about this too...

How hard would it be to change FreeBASIC into an interpreter? I was just thinking that if it was in a library, you could embed the freebasic interpreter into other projects... ie Write your game in C++ with FB scripting.

Would be cool.... but FreeBASIC stuff is compiled yeah? Which would make it hard (if not impossible) to do I imagine. :S

Anyway... I'll shut up now... Wink
Interpretted BASIC sucks balls. Badly-coded BASIC compilers also suck balls, as do badly-coded BASIC wanabes (Euphoria, anyone?).
you can alway do a virtual machine(script engine)
it's not impossible, the compiler generates something like an intermediate representation of the code that's machine independant, then you got different backends for different machines, that translate this representation into whatever code you want. the thing is one has to write a virtual machine that's bad ass enough the backend isn't "such" a big deal, still complicated though...
or you can use threading to start and control another program. Guess that's possible?
Pages: 1 2 3