isNil: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replace - "</dt>" to "")
m (Text replace - "</dd>" to "")
Line 29: Line 29:
<dd class="note"><br>
<dd class="note"><br>
I recently had a strange experience with this command.  I forgot to wrap the name of the variable with quotes, and it returned the opposite of the true null status of the variable.  Just something to watch out for.
I recently had a strange experience with this command.  I forgot to wrap the name of the variable with quotes, and it returned the opposite of the true null status of the variable.  Just something to watch out for.
</dd>
 


<dt class="note">'''[[User:General_Barron|General Barron]]'''
<dt class="note">'''[[User:General_Barron|General Barron]]'''
Line 44: Line 44:
</pre>
</pre>
--[[User:General Barron|General Barron]] 10:37, 30 December 2009 (CET)
--[[User:General Barron|General Barron]] 10:37, 30 December 2009 (CET)
</dd>
 


<!-- Note Section END -->
<!-- Note Section END -->

Revision as of 14:35, 21 October 2011

-wrong parameter ("Arma") defined!-1.00
Hover & click on the images for description

Description

Description:
Tests whether the variable defined by the String argument is undefined, or whether an expression result passed as Code is undefined. The function returns true if the variable is undefined or the expression result undefined (i.e. the expression result is Void), and false in all other cases.
Groups:
Uncategorised

Syntax

Syntax:
Boolean = isnil variable
Parameters:
variable: String or Code
Return Value:
Boolean

Examples

Example 1:
if (isnil ("_pokus")) then {_pokus=0;}

Additional Information

See also:
See also needed

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note

Notes

ColonelSandersLite

I recently had a strange experience with this command. I forgot to wrap the name of the variable with quotes, and it returned the opposite of the true null status of the variable. Just something to watch out for.
General Barron

^ If you don't wrap the name of the variable in quotes, then it will instead read the value of the variable itself. If that variable is a string or code, then the command will use that string or code held by the variable. Example:
_myvar = "_hisvar";
isnil _myvar;
//will return true if _hisvar is null
_myvar = {tank1};
sleep (random 50);
isnil _myvar;
//will return if tank1 is nil, at the time the isnil command is checked (not at the time _myvar is established)

--General Barron 10:37, 30 December 2009 (CET)


Bottom Section