Game Development Community

Possible to use isDefined(var) with array?

by Bas Bergfeld · in Torque Developer Network · 01/04/2012 (10:54 am) · 2 replies

This week I thought I could continue work on my first Troque3D project again and I ran into some trouble using isDefined(). At some point in my scripts I have an array, let's call it $array, and I want to check if it's already defined in a certain function. Using isDefined("$array"); nor isDefined("$array[0]"); seems to work, so is there an other way to see if $array is defined? Or am I just using a wrong parameter syntax?

About the author

Recent Threads

05/23/2012 (12:16 am)
Can't you just check to see if the array even contains anything?

if($array[0] $= "")
     //Array is not defined
08/05/2012 (12:35 pm)
Oh wow I hadn't noticed there was a reply. That will only work if [0] always contains something as long as the array is in use. So if I have an array with [0] $= "" and [1] $= "content" the array does have content, while that check would give a negative.

I can't remember what the problem was though to be honest, after waiting for a reply for a couple of days I just went with a workaround/a different method I guess.