IsRef

Function

Syntax

Tells whether a handle still points at something, so that GetRef() and SetRef() can be used on it safely.

IsRef(<handle>)

Parts

<handle>Any value. Usually an AS HANDLE variable.

Returns

TRUE when the handle is usable. FALSE after ReleaseRef(), after DELETE of the record that holds the target, for a HANDLE variable never assigned, and for any value that is not a handle. It never stops the program.

Good to know

  • The result is TRUE or FALSE, not 1 or 0. IF IsRef(h) = 1 is always false. Write IF IsRef(h), IF NOT IsRef(h) or = TRUE. Str(IsRef(h)) shows true or false.
  • Copies of a handle share its state: after h2 = h and ReleaseRef(h), IsRef(h2) is false too.
  • A handle to a map entry stays true after DeleteMapElement() removes that entry.

Example

hp AS integer = 100link AS HANDLEIF NOT IsRef(link) THEN Console("empty")   ' emptylink = @hpIF IsRef(link) THEN Console("linked")   ' linkedReleaseRef(link)IF NOT IsRef(link) THEN Console("released")   ' released
In the manual : Functions