Core Function IsDeclared
From Sputnik Wiki
(Difference between revisions)
(Created page with "<pre> IsDeclared( <variable name> ) </pre> === Description === Check if a variable has been declared === Parameters === ==== Expression ==== string representing name of the ...") |
(→Remarks) |
||
| (6 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
<pre> | <pre> | ||
| − | IsDeclared( <variable name> ) | + | IsDeclared( <variable name>, <flag> ) |
</pre> | </pre> | ||
| Line 9: | Line 9: | ||
=== Parameters === | === Parameters === | ||
| − | ==== | + | ==== variable name ==== |
| − | + | String representing name of the variable to be checked. | |
| + | |||
| + | ==== flag ==== | ||
| + | |||
| + | Optional; Flag to decide the scope to be checked. | ||
| + | <pre> | ||
| + | 0 = ANY scope (Should be Local first then Global) (Default) | ||
| + | 1 = Local scope only | ||
| + | 2 = Global scope only | ||
| + | 3 = Max depth local scope only (Such as a classes My) | ||
| + | </pre> | ||
=== Return Value === | === Return Value === | ||
| − | Success: Returns | + | Success: Returns true if variable has been assigned. |
| − | Failure: Returns | + | Failure: Returns false if variable doesn't exist yet. |
=== Remarks === | === Remarks === | ||
| + | |||
| + | It is worth noting that even if the variable is $a = null; it will be considered DEFINED since it does exist | ||
=== Example === | === Example === | ||
Latest revision as of 20:06, 14 June 2015
IsDeclared( <variable name>, <flag> )
Contents |
Description
Check if a variable has been declared
Parameters
variable name
String representing name of the variable to be checked.
flag
Optional; Flag to decide the scope to be checked.
0 = ANY scope (Should be Local first then Global) (Default) 1 = Local scope only 2 = Global scope only 3 = Max depth local scope only (Such as a classes My)
Return Value
Success: Returns true if variable has been assigned.
Failure: Returns false if variable doesn't exist yet.
Remarks
It is worth noting that even if the variable is $a = null; it will be considered DEFINED since it does exist
Example
If (!IsDeclared("a")) MsgBox('$a is NOT declared'); // $a has never been assigned $a=1; If (IsDeclared ("a")) MsgBox('$a IS declared'); //due to previous $a=1 assignment