Page 1 of 1

Help with macro

Posted: Thu Mar 14, 2024 9:46 am
by loulou2522
Hi all
Here is what i want to do
toto.s="variable1"
variable1= 100 assigning the value of variable1 to 100 , the var variable1 is given by toto
debug variable1 --> result 100
It's posssible with VB but i don't know hos to do in purebasic
THanks in advance

Re: Help with macro

Posted: Thu Mar 14, 2024 10:16 am
by Fred
I fail to understand what it should do.

Re: Help with macro

Posted: Thu Mar 14, 2024 10:25 am
by breeze4me
I think you mean something like this.
However, PB is not an interpreter language like VB, so variables that will be used must be defined in advance, such as "Define".
Alternatively, you can use a map variable.

Code: Select all

toto.s = "variable1"

Define variable1
Runtime variable1

SetRuntimeInteger(toto, 100)

Debug variable1


Re: Help with macro

Posted: Thu Mar 14, 2024 1:56 pm
by Quin
Variables can be used before declared in PB actually, you just have to make sure to not turn on explicit mode.
Now, why anyone would ever choose to do such a thing is beyond me, mainly because of the number of errors that can arise because of a simple typo, but it does exist.
breeze4me wrote: Thu Mar 14, 2024 10:25 am I think you mean something like this.
However, PB is not an interpreter language like VB, so variables that will be used must be defined in advance, such as "Define".
Alternatively, you can use a map variable.

Code: Select all

toto.s = "variable1"

Define variable1
Runtime variable1

SetRuntimeInteger(toto, 100)

Debug variable1