| USAGE |
/set-var [-d|--def][-g|--global][-q|--quote] varname [expr..] |
| DESCRIPTION |
Sets the named JCShell internal variable.
(Refer to /clear-vars or /list-vars for additional information)
|
| PARAMETER |
| Name | Description | Required |
| varname |
Name of the variable. |
Yes |
--+- -d-----+--->
! !
+- --def -+
|
Update/create variable in defining scope. If var not defined use local scope. |
No |
--+- -g -------+--->
! !
+- --global -+
|
Update/create variable in global scope. |
No |
--+- -q ------+--->
! !
+- --quote -+
|
Do not evaluate arguments as expression. If multiple arguments are used, an array will be created. |
No |
| expr.. |
Shell expression |
No |
|
| EXAMPLE |
Example 1: Create global variable "VAR1" with value "xyz"
/set-var VAR1 xyz
Example 2: Purge global variable "VAR1"
/set-var VAR1
Example 3: Create global variable "n1" with value "10"
/set-var n1 10
Example 4: Create global variable "n2" with value "2"
/set-var n2 2
Example 5: Set global variable "n1" to new value "20"
/set-var n1 $(/expr ${n1} + ( ${n2} * 5 ) )
Example 6: Create global variable "b1" with value "true"
/set-var b1 true
Example 7: Create global variable "b2" with value "true"
/set-var b2 $(/expr ( ${n1} >= 20 ) && ${b1} )
Example 8: Create global variable "NUMS" with space separated value list "1 2 3"
/set-var -q NUMS 1 2 3
Note: You can also use the short form: NUMS[*]=1 2 3
Example 9: Appends global variable "NUMS" with values "3 4 5" to "1 2 3 3 4 5"
NUMS[#]=3 4 5
|
| CONDITIONS |
None.
|