Variables are pieces of data that can be written and read through the events' system. A Variable value can be interpreted as a string, number, date, collection of Data Master's records or anything depending on the calculations applied on it. Variables' lifespan is that of the simulation of the prototype.
To create a new Variable, first select the option 'Variables' from the View menu to show the corresponding panel. Then follow the steps:
Click on the magenta 'plus' button. A dialog will appear.
Introduce a name for the Variable in the input 'Name'. The name of the Variable must be unique per prototype in order to identify them properly.
(Optional) Introduce a default value in the input 'Default Value'. This will be the value the Variable will take when starting the prototype's simulation.
Click on Ok to create the Variable or click Cancel to cancel the changes.
To modiy the name or default value of an existing Variable, double-click on it on the Variables panel or right-click on it and select 'Edit'. Modify the parameters in the dialog and click on Ok.
To delete a Variable, right-click on it on the Variables panel and select 'Delete'.
You can store any kind of information in a Variable during simulation using events and interactions. Specifically, storing a value to a Variable must be done through a 'Set Value' action using the desired variable as the action's target. Justinmind Prototyper offers you two different ways to create this action for a Variable:
To store the value from a screen's widget to a Variable just drag the widget and drop it on the desired variable on the Variables panel. This will create an 'On page unload' event with an action that sets the widget's value to the variable.
To store the value from a screen's widget or any other data source (including the result of complex calculations) use the Events panel to create a 'Set Value' action (see Actions for more information about this action). Type a constant as a value or click on the 'Calculated' button to use a data source or construct a calculation.
You can display the contents of a Variable during simulation also using a 'Set Value' action and setting the Variable as the data source. Justinmind Prototyper offers you two different ways to create this action:
To display the value of a Variable in a screen's widget just drag the Variable and drop it on the screen's widget. Notice that the target widget must be compatible with the Variable's value type. This will create an 'On page load' event with an action that sets the Variable's value to the widget.
To display the value of a Variable on a screen's widget use the Events panel to create a 'Set Value' action (see Actions for more information about this action). In the Interactions dialog select the screen's widget as the action's target, click on the 'Calculated' button and create an expression using the Variable as the only data source.