I'm intermittently teaching someone about programming with NWP macros. I was recently trying to explain the concept of variable typing. I wrote a tiny piece of example code:
Code: Select all
$Name = 'George'
$Number = 3
$FullName = $Name + $Number
It didn't happen. The macro ran, and when I added a prompt command to show me the value of $FullName, it was 3.
OK, I get it, sort of: the macro language determined that a sum must have a numeric value, and since 'George' is not a number, it treated it as 0, added 3, and gave 3 as a result. I don't like that

What I don't know, and the single paragraph on variables in the macro reference manual does not make clear, is what emerges when one does a type-crossing operation. If I had had to guess the outcomes of $FullName = $Name + $Number, my guesses would have been, in order:
1. Error (type mismatch)
2. 'George3' (treating the result as a string, since the first variable was a string, and concatenating -- or just defaulting to concatenating whenever there is a string)
3. 'George' (retaining the first value, since it was defined as a string)
4. Using whatever type $FullName had before, if it had a type (which it didn't in this case)
Obviously I got outcome 5.

I try not to create type mismatches, because I consider them an error even if NWP doesn't
