Help with macro

Just starting out? Need help? Post your questions and find answers here.
loulou2522
Enthusiast
Enthusiast
Posts: 553
Joined: Tue Oct 14, 2014 12:09 pm

Help with macro

Post 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
Fred
Administrator
Administrator
Posts: 18351
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Help with macro

Post by Fred »

I fail to understand what it should do.
breeze4me
Enthusiast
Enthusiast
Posts: 633
Joined: Thu Mar 09, 2006 9:24 am
Location: S. Kor

Re: Help with macro

Post 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

Quin
Addict
Addict
Posts: 1135
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: Help with macro

Post 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

Post Reply