Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script parse problem
#1
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 ;-)
Reply
#2
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
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#3
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.
i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Reply
#4
major thnx guys! without you i might also come up with it, but after some big time of thinking ;-) but anywayz major thnx!
Reply
#5
my way is faster, toonski. Smile
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)