Scripting - Chapter 3: Variables
Variable? Is that a new insult?
No, it's not an insult. The variable is a very important element in programming. It is defined by a name and a value. This value can vary along the script.
If you don't understand, keep on reading and you'll find out what it's all about.
Declaring a variable
Reading a variable
You have to put this sign "$" in front of the variable.
FRUIT="pear" POL_SetupWindow_message "I like to eat a $FRUIT" "My favourite fruit"
PlayOnLinux Wizard My favourite fruit
I like to eat a pear
You can use variables in any message, menu, etc.
Do you remember this code?
POL_SetupWindow_menu "What do you want to eat tonight?" "Tonight's menu" "Carrots Potatoes French-fries" " "
The result is actually sent to the variable $APP_ANSWER. This is the way to retrieve user's choice:
POL_SetupWindow_menu "What do you want to eat tonight?" "Tonight's menu" "Carrots Potatoes French-fries" " " POL_SetupWindow_message "Tonight we'll be eating $APP_ANSWER, a very good choice." "Tonight's menu"
POL_SetupWindow_browse and variables
For POL_SetupWindow_browse, it is the path to the file selected by the user that is stored into $APP_ANSWER.
POL_SetupWindow_question and variables
For POL_SetupWindow_question, $APP_ANSWER will contain TRUE if the user answered yes, and FALSE if (s)he answered no.
Previous: Chapter 2: Basic Functions
Next: Chapter 4: Conditions