Skip to main content

This documentation is for an older version of this product. See the latest version of this content.Opens in a new tab

$Get 関数

$Get 関数を使用すると、変数または配列位置の有無にかかわらず、確実に変数または配列の場所にアクセスします。変数が存在する場合、$Get は値を返します。変数が存在しない場合、$Get は空文字列か $Get の 2 番目の引数として指定したオプションの既定の文字列を返します。

ターミナル


USER>write $get(fred)

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

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

定義の有無が不確かな配列にアクセスしたい場合、If$Data を使用してコードを記述することもできますが、$Get を使用する方が 1 ステップで完了するため簡単です。

ターミナル


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