Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.Opens in a new tab

For information on migrating to InterSystems IRISOpens in a new tab, see Why Migrate to InterSystems IRIS?

Option Explicit

スクリプト・レベルで、そのスクリプトにあるすべての変数の明示宣言を強制します。

Synopsis

Option Explicit

引数

なし

概要

Option Explicit 文を使用する場合は、すべてのプロシージャよりも前に置かなくてはなりません。

また Dim 文を使用して、すべての変数を明確に宣言する必要があります。宣言されていない変数を使用しようとすると、エラーが発生します。

Note:

Option Explicit は、メソッドの内側では使用できません。

以下の例は、Option Explicit 文の使用法を示しています。

Option Explicit    ' Force explicit variable declaration.
Dim MyVar          ' Declare variable.
MyInt = 10         ' Undeclared variable generates error.
MyVar = 10         ' Declared variable does not generate error.

メモ

Option Explicit を使用すると、既存の変数名を間違って入力したり、変数のスコープが明確でない場合にコード内で混乱したりすることのないようにできます。

FeedbackOpens in a new tab