enum-id Action.
78 #Start. *> Start is a reserved word so use '#' symbol
78 #Stop.
78 #Rewind.
78 #Forward.
end enum.
enum-id Status.
78 Flunk value 50.
78 Pass value 70.
78 Excel value 90.
end enum.
class-id MainClass.
method-id main static.
declare a = type Action::Stop
if a not = type Action::Start
display a & " is " & a as binary-long *> Prints "Stop is 1"
end-if
display type Status::Pass as binary-long *> prints 70
display type Status::Pass *> prints
end method.
end class.
列挙のサンプルも参照してください。このサンプルは、[スタート > すべてのプログラム > Micro Focus Enterprise Developer > サンプル > Visual COBOL サンプル] の [COBOL for .NET] の下にあります。
コンパイラーは、列挙の値を含む配列を返す「values」という静的メソッドを追加します。このメソッドを PERFORM THROUGH 定数と一緒に使用すると、列挙型の値を反復できます。
enum-header の後には、次の内容で構成される作業場所節が続きます。