IsFormValid

From GECK
Jump to: navigation, search


A function added by the Fallout Script Extender.

Description

Returns True (1) if the object passed in the ref variable is valid, meaning it holds either a Reference or a Base Form. Returns False (0) if the object stored in the variable is not currently loaded in memory (for instance, a non-persistent reference) or if the variable doesn't hold any object.

This is useful in cases where an invalid ref variable will cause the script or game to crash.

Syntax

[help]
(bool) IsFormValid refVar:ref 

Example

  • If one expects a ref variable to hold either a Base Form or a Reference, and that either should be used to call functions, IsReference can be used to further narrow down the results after IsFormValid has confirmed that the ref variable is valid.

Implementation:

ref SomeRef
int iType

if IsFormValid SomeRef
   if IsReference SomeRef != 1
      ; SomeRef is a valid Base Form.
      let iType := GetType SomeRef
   else
      ; SomeRef is a valid Reference.
      let iType := SomeRef.GetType
   endif
endif

See Also