Persistents Structure

The Persistents struct provides methods to collect, create and test persistent global variables.

   

Methods:

persistents.show()

Displays a list of persistent globals and their value.

   

persistents.remove <var_name>

Removes the named persistent global from the persistent global pool. The variable remains as a global variable and retains its value.

   

persistents.removeAll()

Removes all persistent globals from the persistent global pool. The variables remain as global variables and retain their value.

SCRIPT:

a= "Hello world"
persistent global a
persistent global b=box()
persistents.show()
persistents.remove #a
persistents.removeall()
a
b

SCRIPT:

"Hello world"
OK
$Box:Box02 @ [0.000000,0.000000,0.000000]
a: "Hello world"
b: $Box:Box02 @ [0.000000,0.000000,0.000000]
OK
OK
OK
"Hello world"
$Box:Box02 @ [0.000000,0.000000,0.000000]
persistents.gather() 	 

This method returns an array of all persistent global variable names as <name> values.

Available in 3ds Max 2008 and higher. Previously available in the Avguard Extensions.

   

persistents.make <global var name>   

This method makes the specified global variable name persistent.

The name specified must be a global variable's name, otherwise a runtime error is thrown. See globalVars structure.

Available in 3ds Max 2008 and higher. Previously available in the Avguard Extensions.

   

persistents.isPersistent <global var name> 

Returns true if the specified global variable name is persistent, false if it is not persistent.

Available in 3ds Max 2008 and higher. Previously available in the Avguard Extensions.

EXAMPLE

global aVar  --define a global variable
--> OK  --done!
persistents.isPersistent #aVar --is it persistent?
--> false  --it is not!
persistents.make #aVar --make the existing global persistent
--> OK  --done!
persistents.isPersistent #aVar --see if it is persistent now
--> true  --now it is!
persistent global aNewPV --declare a variable as persistent global
--> undefined  --done, variable has a value of undefined
persistents.isPersistent #aNewPV --then see if it is persistent
--> true  --it is!
persistents.isPersistent #anUndeclaredVar --check an undeclared var.
--> false  --it is not persistent 

See Also