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 > Samples] の COBOL for JVM の下にあります。
コンパイラは、列挙の値を含む配列を戻す 'values' という静的メソッドを追加します。このメソッドと PERFORM THROUGH コンストラクトを一緒に使用して、列挙タイプの値を反復できます。
enum-header の後には、次の内容で構成される作業場所節が続きます。