Qbasicnews.com

Full Version: Script parse problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Ok i've made a script engine which works fine, but the problem is how can i read variables and change them in my program for example:

in my program
i have a integer called 'gold' which holds the value 40

now i don't want my in my parser that it looks up for this string 'gold' and then goto the function where it read the value after it, but i want that i read 'gold' in, 'gold' is stored in a string and then reconized by my program as the integer gold.

it's a bit unclear maybe but if you need more explaination i will give it ;-)
First I'd put each unique variable in a string. For each variable found, if it's unique: rename it to var(i) where "i" is the ith unique variable found. Otherwise, find the corresponding i-value and replace the string with that.

Then I'd know exactly which memory location each variable refers to. Smile
you can't change variables in your program because variable names are lost when you compile.

what you could do is this:

dim varnames(50) as string
dim varvalues(50) as integer

then, assign "gold" to one of the varnames values, and every time your script references a variable, search varnames for that string and change the value of varvalues for the index you find the name in varnames.
major thnx guys! without you i might also come up with it, but after some big time of thinking ;-) but anywayz major thnx!
my way is faster, toonski. Smile