![]() |
![]() |
VariablesVariables and data types |
|||||||
Basic syntaxA variable identifier is composed by a '%' (percent) sign followed by a sequence of letters, digits or underscores.Examples of valid variable names are: %i,%variable,%MyVar,%1,%thisisavar,%2ndName,%_hidden Local and global variablesVariables can be local or global.Local variables preserve their contents only inside the scope of a single script. Global variables are shared between all the scripts and preserve their contents until they are explicitly unset or until KVIrc quits. By default KVIrc assumes that the variables you're referencing are local. If you want to force the scope of a variable to global you need to pre-declared it with the global keyword.
If you have executed the example above from a file (by the means of parse) then now you can type
If you also try
Older KVIrc versions recognized global variables when they were starting with an uppercase letter and local ones when the initial letter was lowercase. This method was incoherent since the other parts of the language are case insensitive. The case sentive method is still supported for backward compatibility but is deprecated and the parser warns about it. Variable typesKVS has three main data types: scalars, arrays of scalars and associative arrays of scalars (also known as hashes).Scalars The scalars are simple variables containing a single value (a string or an integer).
The arrays are collections of items indexted by integers. An easy way to create an array is to use the $array function.
|