Jump to content

Recommended Posts

I need to execute the below code only if the global variable v_TLSAO is not empty. I'm new at this so I'm having a hard time figuring out isnil functionality.

 

[v_TLSAO] call LARs_fnc_deleteComp;

Share this post


Link to post
Share on other sites
1 hour ago, LifeSnatcher said:

I need to execute the below code only if the global variable v_TLSAO is not empty. I'm new at this so I'm having a hard time figuring out isnil functionality.

 

[v_TLSAO] call LARs_fnc_deleteComp;

What is v_TLSAO ? "empty" lets me think it's already an array. In this case, check if you need an array of array...

To check if an array is empty: myArray isEqualTo [ ]

Share this post


Link to post
Share on other sites

v_TLSAO is a string var. it doesn't always have a value.

 

Isnil examples only show what to do on true. i only want it to execute when its false. how do i reverse the condition, what is the syntax.

Share this post


Link to post
Share on other sites
if !(isNil "somevariable") then {
    // whatever
};

 

Also very useful:

_pv = missionNamespace getVariable ["somevariable", 0];

getVariable can return a specified default value if the variable is not defined.

Share this post


Link to post
Share on other sites
4 hours ago, LifeSnatcher said:

v_TLSAO is a string var. it doesn't always have a value.

 

 

You need to be a bit clearer. It's a string - when you say it doesn't have a value, do you mean it's empty string or undefined?

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×