GetVariableList
Script function

world.GetVariableList

DOC_scripting Read about scripting

Type

Method

Summary

Gets the list of variables

Prototype

VARIANT GetVariableList();

DOC_data_types View list of data type meanings


Description

Returns an array of all the variables currently defined.


VBscript example

dim varList

varList = world.GetVariableList

If Not IsEmpty (varList) Then
  
  For Each v In varList 
    world.note v & " = " &  world.GetVariable (v)
  Next

End If



Jscript example

variablelist = new VBArray(world.GetVariableList()).toArray();

if (variablelist)  // if not empty
 for (i = 0; i < variablelist.length; i++)
   world.note(variablelist [i] + " = " + 
       world.GetVariable(variablelist [i]));



PerlScript example

foreach $item (Win32::OLE::in ($world->GetVariableList))
 {
 ($key, $value) = ($item, $world->GetVariable ($item));
 $world->note($key . " = " . $value) if (defined ($key));
 }



Python example

variablelist = world.GetVariableList
if (variablelist ):
  for v in variablelist : world.Note (v + " = " +
                  world.GetVariable(v))



Lua example

-- show all variables and their values

for k, v in pairs (GetVariableList()) do 
  Note (k, " = ", v) 
end



Lua notes

Under Lua this function returns a table of all variables and their values, 
keyed by the variable name.

Thus you can directly access variables from the table, like this:

-- show value for variable "victim" ...

print (GetVariableList ().victim)



Return value

If there are no variables then the return value is empty. Use "IsEmpty" to test for this possibility.
Otherwise, it returns a variant array containing the names of all the variables. Use "lbound" and "ubound" to find the bounds of the array of variables (ie. the number of variables in the list). You can then use "GetVariable" to find the contents of each variable.




See Also ...

Topics

DOC_Arrays Arrays
DOC_plugins Plugins
DOC_scripting Scripting
DOC_variables Variables

Functions

FNC_DeleteVariable DeleteVariable (Deletes a variable)
FNC_GetVariable GetVariable (Gets the contents of a variable)
FNC_SetVariable SetVariable (Sets the value of a variable)

(Help topic: function=GetVariableList)

DOC_contents Documentation contents page