Feature #11982

typeName for non-existing variable should throw an error

Added by Benny almost 7 years ago. Updated almost 7 years ago.

Status:Assigned Start date:07/14/2010
Priority:Normal Due date:
Assignee:- % Done:


Category:Scripting: Problem
Target version:-
Affected ArmA II version: First affected ArmA II version:
Reproduced by another DH user:Yes Single / Multi Player?:
I am using some Mods:No BIForumURL:
I am using:OA only NGUrl:
Reproducible for you:Yes WIKIurl:
Related to content of DLC:


I've only tested this in OA, but i assume that it's the same in Vanilla.

The typeName command is unable to handle a statement with a nil getVariable.
In the code bellow, the else part is not even triggered.

        File used for the test: init.sqf
    Purpose: Test typeName command with nil getVariable
    Affected Version: 
        OA, (Probably Vanilla too)
    Current Situation:
        The typeName return an empty string if the getVariable is nil but typeName is unable to handle it.

    According to the wiki: http://community.bistudio.com/wiki/typeName
        "If the argument is  nil (undefined), it returns an empty string." 

diag_log format ["        DEBUG: typeName=%1",typeName(missionNameSpace getVariable 'myvariablewhichdontexist')];

//--- This statement won't even work like it should
if (typeName(missionNameSpace getVariable 'myvariablewhichdontexist') == "") then {
    diag_log format ["        DEBUG: typeName=%1   The variable is nil",typeName(missionNameSpace getVariable 'myvariablewhichdontexist')];
} else {
    //--- The else part doesn't even work.
    diag_log "        DEBUG: typeName failed to handle the nil value";

After running this code, here's what i get in my rpt.

"        DEBUG: typeName=" 

Repro's attached.

test.Zargabad.zip (1.1 kB) Benny, 07/14/2010 11:57


Updated by Xeno almost 7 years ago

It's an expected behaviour and not a bug. There is no typeName for a nil (or non existent) variable because it has no type.

Though it should at least throw an error then.

Updated by Fireball almost 7 years ago

  • Status changed from New to Feedback

Can it be workarounded?

Updated by Benny almost 7 years ago

Yes, it uses more variable but it's do-able, just a shame the empty space returned over nil type cannot be handled, like Xeno said, it should at least return an error.

_var = missionNamespace getVariable 'myvariablewhichdontexist';
if (isNil '_var') then {
  diag_log 'nil';
else {
  diag_log 'not nil';

Updated by kju almost 7 years ago

  • Due date set to 09/01/2010

Updated by Fireball almost 7 years ago

  • Tracker changed from Bug to Feature
  • Subject changed from typeName command bug (nil type & getVariable) to typeName for non-existing variable should throw an error
  • Due date deleted (09/01/2010)
  • Status changed from Feedback to Assigned
  • Affected ArmA II version deleted (1.52.71816)
  • Reproduced by another DH user changed from No to Yes

Also available in: Atom PDF