Is it possible to alias the contents of a variable?

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
Argent Star
Kobold
Posts: 18
Joined: Sun Aug 07, 2011 4:03 pm

Is it possible to alias the contents of a variable?

Post by Argent Star »

In many programming languages, it is possible to use the contents of a variable in an expression rather than the variable it's self. I was wondering if there was a way to do that in RPT macros.

What I want to do is put the name of a property in a variable and then use the name inside the variable to access the property.

Example:

Code: Select all

<!--Where using @ in front of a variable name would substitute the contents of the variable in the equation-->
<!--below I want to set the value of the property prop to 10-->
[r:propName="prop"]
[r:@propName=10]

User avatar
JML
Dragon
Posts: 515
Joined: Mon May 31, 2010 7:03 am
Location: Blagnac, France

Re: Is it possible to alias the contents of a variable?

Post by JML »

I'd say:

Code: Select all

[h: setProperty(propName, 10)] 
The whole story is there: Wiki: setProperty().

User avatar
JonathanTheBlack
Dragon
Posts: 544
Joined: Mon Jun 28, 2010 12:12 pm
Location: I'm the worm...

Re: Is it possible to alias the contents of a variable?

Post by JonathanTheBlack »

Couldn't you just use eval()?

User avatar
aliasmask
RPTools Team
Posts: 9031
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: Is it possible to alias the contents of a variable?

Post by aliasmask »

Code: Select all

[H: propName = "prop"]
[H: set(propName,10)]
<!-- OR -->
[H: eval(propName+"=10")]

Post Reply

Return to “Macros”