Skip to main content

$Get Function

You use the $Get function to safely access a variable or array location, whether or not it exists. If it exists, $Get returns its value. If it doesn't exist, $Get returns the empty string, or an optional default string you specify as the second argument of $Get.

Terminal


USER>write $get(fred)

USER>write $get(fred, 2)
2
USER>set fred = 1

USER>write $get(fred, 2)
1
USER>

Sometimes you want to access an array location, but you're not guaranteed that it exists. You can write code using If and $Data, but it's easier to use $Get to do it all in one step.

Terminal


USER>set a(3) = "yes"

USER>set x = "no" if $data(a(3)) {set x = a(3)}

USER>write x
yes
USER>kill x

USER>set x = $get(a(3), "no")

USER>write x
yes
USER>
FeedbackOpens in a new tab