3 Replies Latest reply: Jan 10, 2017 4:04 AM by Marcus Sommer RSS

    Alt() works differently in script and in front end

    Jonathan Dienst

      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