Creating a variable
To create a new variable go to the “Variables” tab and click the “+ Add Variables” button.
Variables are named alphabetically and a new variable will be created with the name next in line of the alphabet. i.e. when variables $a and $b already exist, variable $c will be created.
Adding an alias
When you click on the name of the variable, you can rename the variable by giving it an alias. Note that the original value will also still be available for use.
We can now refer to the variable in the pictures with $a and with $solution.
Rules for alias names are that an alias
must start with a letter (not a number or a special character)
can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
Variable fields and buttons
(Optional) variable alias.
Variable definition (PHP coded), see this article
add link to PHP functions
Preview of the variable.
With this icon, you can drag and drop variables to change their order in the variables list. Names of variables will remain unchanged.
Delete the variable. This is only possible if the variable is not used anywhere. If you try deleting a variable that is used somewhere, an error and a usage-popup will appear that tells you where the variable is used.
7. Choose the number of decimal digits to display. The default is 0, meaning that decimal numbers are rounded to the nearest integer.
8. If you check this box (and the number of decimal digits is >0), then trailing zeros will be removed.
9. Save any changes you made to the variable.
10. Write down a comment for a variable. Example:
11. Open the usage-popup, see (4).
More on variable definitions
Variable definitions can be anything ranging from (random) numbers to strings to pieces of code etc. Below are some very basic examples.
As mentioned before, these Definitions are PHP coded. More information on using PHP code in variables can be found here.
PHP is very limited if it comes to mathematical calculations. For example, it is not easy to do differentiation using just PHP. If we want to do differentiation or another mathematical operation in the variables, we need another programming language. At this moment, the languages Python, Maxima and R are supported. Click here to learn how to define variables using Maxima and here define variables using Python. For now, there is no article explaining how to define variables using R, but some information is provided in the authoring manual under “sw_R(a)”.
Additional information about authoring variables with decimal values can be found here.