April 4, 200620 yr Gurus, Bill and all, you guys are an invaluable resource. My next question: I used the construct: (L:First, enum) (L:Second, enum) 2 * + ...etc... And it's working just fine. But as my gauge gets bigger, I'm realizing that I need to re-use that first RPN evaluation statement again and again. It makes sense to me to store it in an L:Var, for repeated use and to simplify later calculations, but I'm getting stuck. This doesn't work: (L:First, enum) (L:Second, enum) 2 * + (>L:Result)Basically, L:Result stays zero. What's the best way to go about it? Thanks.---Will
April 4, 200620 yr I can try this one but you want to let Tom, Jan, Bill, Jon (or someone else who knows for sure!) double check this:I'd try:<Macro Name="TheMacro"> @1 @2 2 * + </Macro>The @1 and @2 are place holders for arguments to be passed in, just like a function.Then call it with:<Value> @TheMacro((L:First, enum),(L:Second, enum)) </Value>To set the result into an L:Var, simply use:@TheMacro((L:First, enum),(L:Second, enum)) (>L:Result,enum)A nice thing about macros is that they don't have to be inside of elements or value tags in order to do the behind the scenes manipulations.I am a macro newbie myself... get a second opinion on this and I'm sure that there are many points I'm missing too. But, as far as I know, that example should meet your needs.Scott / Vorlin
April 4, 200620 yr Errff, macros are scary, but that's how we learn, right? Thanks Scott. Any other takers?---Will
April 4, 200620 yr Author Maybe for your understanding.The reason why your original assignment didn't work is that you omitted the unit in (>L:Result). Probably the most common mistake in XML coding (at least for me :-) )About macros vs. "saved" calculations:Both methods are valid and have their pro's and con's, and it's not always that trivial which one to choose.But realise that there IS a big difference.In your first line, (L:Result,enum) gets a value assigned ONCE, which is fixed through the subsequent code. Even if L:First and L:Second are changed later on in the code.If you use the macro form: the value of L:Result is caculated EACH time at the moment you call the macro in the code, and uses the values of L:First and L:Second at the moment of calling.So realise this difference.Also, you may pay a performance penalty in the gauge, because the macro calculation is done at each time you call it in the code (which could cause a fps hit for very complex macros). Not really an issue, it's just so you know :-)Cheers, Rob Barendregt
Create an account or sign in to comment