Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Consider the following script fragment:
Set x1 = 1;
Let x2 = 2;
Let z1 = Alt(x1, 100);
Let z2 = Alt(x2, 200);
Let e1 = IsNum(x1);
Let e2 = IsNum(x2);
This produces the following results:
Notice that the Alt(x1, 100) considered x1 to be non-numeric, whereas IsNum(x1) sees x1 as numeric. Furthermore, in the front end, we get this:
So x1 is being seen as numeric by Alt() and IsNum() in the front end expressions, and in the script it is considered numeric by IsNum(), but non-numeric by Alt().
In the case where this behaviour was observed, the Set x1 = 1 expression is dynamically generated from a configuration file. The Alt() was required to provide a default if the configuration file did not have a definition of x1.
The workaround is to change the config loader to generate the values with Let, but if that is not an option, use an expansion:
Let z1 = Alt($(x1), 100);
Version 11.2 SR15 11.20.13405.0
I'm not sure if this behaviour is really unexpected then Set x1 = 1; assigned a string to the variable and Let x2 = 2; creates an dual-value with 2 as string and 2 as numeric value. Therefore differ the alt-results by the z-variables. And I think isnum() instead will be evaluate it's input-value and at first check if the value is an (valid) dual-value and if it's not then it will check if the string-representation could be evaluated as number - and in this case both checks on the e-variables will be true.
Further I think the front-end treated the x1 variable as number because it sees it just as 1 and not as '1'.
- Marcus
Marcus
That's my interpretation of the behaviour too (and that's why Let x = 1 does not have the problem) - it just seems inconsistent to me and it caused a hard to track down bug. IMO Alt() should act like IsNum() does and be the same in the script and in the front end.
Maybe hic could give some backgrounds if it's behaved expectedly or not and why there are differences between alt() and isnum().
- Marcus