3

Allow declaring of variables. Please read.

There is a lot to this suggestion, but please read it all, it’s worth it.

Declaring a variable changes how a variable is used, until that variable is next named in a Declare Variable action.

Action for Declare Variable has three values:

Variables:

     A comma separated list of variable names.

Assign Out:

     This option controls what happens when the value of an unset variable is referenced.

     standard:

          The variable reacts as at present.

     unset:

          When a variable is declared with this option, instead of coding:

if %vara Set
    %varb = %vara
else
     variable clear %varb
endif

          You can code:

declare vara AssignOut=unset
%varb = %vara

     null:

          When a variable is declared with this option, if it is unset…

 declare varb AssignOut=null
%vara = a
variable clear %varb
%varc = c
%vard = %vara%varb%varc

          %vard would hold “ac”

          Actions would have to take account of the fact that they might now receive a null value. For optional fields, the best option would be to treat it as no value specified. Mandatory fields could be handled in one two ways. One option would be to always fall back to the old style: So if a mandatory field was set to %vara%varb%varc and they were all unset, the field would be treated as the string “%vara%varb%varc”. Perhaps a better way would be to fail with an error, unless there is some other action that could be taken. For example a Flash action could just not issue a toast if the input is null.

     0:

          Assigns 0 if unset.

     false:

          Assigns the string “false” if unset.

Assign In:

     This third, and last option controls what happens when an unset variable is assigned to the declared variable.

     normal:

          The action is performed according to how the other variable is declared, or as at present if it has not been declared.

     unset:

          The action is performed as if the other variable is declared AssignOut=unset. For example:

declare varb AssignOut=null AssignIn=unset
%vara = a
variable clear %varx
%varb = %varx
%varc = c
%vard = %vara%varb%varc

          %vard would hold “ac” 

Arrays are probably best treated as always declare the whole array. Ie don’t allow declaring of %arr(1) and the declaration of %arr applies to %arr(1) aswell.