Hi everyone,
a bit of a theoretical question here. I'm currently writing a JSL Scripting tutorial for my colleagues and so I am trying to make sure I have a good understanding of the way JSL works.
I once read on a forum that you should always use an 'Else' statement inside an 'If' loop, even if that meant adding Empty() as the 'Else' statement.
To see the difference, I tried playing around with the script editor:
y=if(1>2, 1);
z= if (1>2, 1 , Empty());
Show (y);
Show (z);
Show (Is Missing (y) );
Show (Is Missing (z) );
Show (Is Empty (y) );
Show (Is Empty (z) );
x= If (y==z, "true", "false");
Show (x); <BR /><BR />// results :<BR />y = .;<BR />z = Empty();<BR />Is Missing(y) = 1;<BR />Is Missing(z) = 1;<BR />Is Empty(y) = 0;<BR />Is Empty(z) = 1;<BR />x = .;
So the value Empty() is both a missing and an empty value but '.' is missing but not empty. What difference does that make ? Given the fact that they both return a missing value when used in comparison operators, why should I bother using Empty() as an 'Else' statement ?
This also illustrates the fact that when the condition tested in the if statement returns missing, it is neither true nor false, so the loop returns neither of the two statements, which is always good to keep in mind!