Initially this did not work because it worked for actual expressions but not for numeric values. Thus "10+4+2" would evaluate to "16" but "16" would give an evaluation error. I got around this by prefixing the contents with "0+". Thus when the contents are only a number, the number becomes an expression such as "0+16". If the contents are an expression then adding 0 to it does not change the value.
The problem that I am running into is that I have a helper macro that dumps all of the currently set attributes to the GM. This works great as long as the attributes are of one of the types mentioned above (i.e. numeric or expression). However, I also have a couple of expressions which are text. When I evaluate these using the same process as above, MapTools treats the text as a variable and (because it is not set) prompts the user for it.
Is there a way to determine if a string is text, number of expression? I know there is a isNumeric which identifies pure numeric entries but I have not found a good way to differentiate between string expressions and actual text strings (i.e. so that I can branch and not eval() them).
I would like to do something like:
Code: Select all
[r, if(isExpression(propVal)): prop + " is " + eval(propVal) ; prop + " is " + propVal ]