*>---------------------------------------------------------------- *> *>iii/Win コンソール・インターフェース のサンプル・プログラム *> コンパイラ: Micro Focus COBOL *> *>---------------------------------------------------------------- identification division. program-id. CsiDemo. author. InterPro. environment division. configuration section. source-computer. AnyWindowsPC. object-computer. AnyWindowsPC. data division. working-storage section. 01 work-data. 02 den-no pic 99999. 02 shift-cmd pic x(04). 02 sel-no pic 9(04) comp. 02 qty pic 9(05) comp. 02 evno pic 9(06) comp. 02 item-id pic 9(06) comp. 02 eventno pic 9(04) comp. 02 chainged pic 9(04) comp. 02 complete pic 9(04) comp. 02 field-code pic x(01). 02 fld-kin pic 9(10).99. 02 ukingaku pic s9(09)v99 comp-3. 02 skingaku pic s9(09)v99 comp-3. 02 utanka pic s9(07)v99 comp-3. 02 stanka pic s9(07)v99 comp-3. 02 tflen pic 9(04) comp. 02 qflen pic 9(04) comp. 02 lnno pic 9(04) comp. 02 arno pic 99. 01 得意rec. 02 得意コード pic x(05). 02 得意先名 pic x(30). 01 商品rec. 02 商品コード pic x(05). 02 商品名 pic x(20). 02 販売単価 pic x(9). 02 仕入単価 pic x(9). 01 item-rec occurs 5. 02 item-code pic x(05). 02 item-name pic x(20). 02 item-qty pic 9(05) comp. 02 item-utnk pic s9(07)v99 comp-3. 02 item-stnk pic s9(07)v99 comp-3. 02 item-ukin pic s9(09)v99 comp-3. 02 item-skin pic s9(09)v99 comp-3. procedure division. *>---------------------------------------------------------------- 業務メニュー section. *>---------------------------------------------------------------- *> PSRUNをイニシャライズして、業務メニューを表示 display "INIT|C" display "SCREEN|URIMNU.SCR" move 1 to sel-no move 10001 to den-no *> 業務メニューの選択(6番のみ有効)([F2]:終了) perform test after until sel-no = 132 display "@SELECT|" sel-no accept sel-no if sel-no <= 99 evaluate sel-no when 6 display "SCREEN|URI122.SCR" display "DATESET|DATE" display "PUT|DVCODE|" den-no move 0 to evno perform 伝票入力 until evno = 133 display "SCREEN|URIMNU.SCR" when other display "ALARM|23|6|項目C以外は選択できません。" end-evaluate end-if end-perform. 処理終了. display "QUIT" stop run. *>---------------------------------------------------------------- 伝票入力 section. *>---------------------------------------------------------------- *> フルスクリーン型の画面入力(メニューID01= [F2]:終了) display "@INPUT|/NEXTV" accept evno if evno = 133 go to 伝票入力-出口 end-if *> 数量欄、単価欄への入力の結果、フィールド値が変化していれば金額表示を更新 display "@ICHANGED" accept chainged if chainged = 1 display "@CODE|/CUR" accept field-code evaluate field-code *> 数量欄 when "Q" perform 売上金額更新 perform 仕入金額更新 *> 販売単価欄 when "U" perform 売上金額更新 *> 仕入単価欄 when "I" perform 仕入金額更新 end-evaluate end-if *> メニュー項目が選択されていた場合は、そのID別に処理分岐 if evno = 132 display "@QUERY|MN_SELECTNO" accept item-id evaluate item-id *> ID08=[F1]:ヘルプ画面表示:内容はテキスト・ファイルから自動ロード when 08 display "WINDOW|URIHLP.SCR" display "@INPUT|/EVENT" accept eventno display "RESTORE" *> ID07=[F9]:画面上の入力の完了を確認してファイル書き込みへ when 07 display "@ICCHECK" accept complete if complete = 0 compute den-no = den-no + 1 perform ファイル出力 end-if *> ID06=[F6]:印刷のウィンドウ処理へ when 06 perform 印刷処理 *> ID0501:商品のウィンドウ選択へ when 0501 perform 商品一覧 *> ID0401:得意先のウィンドウ選択へ when 0401 perform 得意先一覧 *> ID03=[F5]:アイテム部の行挿入 when 03 move "PUSH" to shift-cmd perform 行シフト *> ID02=[F4]:アイテム部の行削除 when 02 move "POP" to shift-cmd perform 行シフト when other display "ALARM|23|6|該当デ−タの登録がありません。" end-evaluate end-if. 伝票入力-出口. *>---------------------------------------------------------------- 売上金額更新 section. *>---------------------------------------------------------------- *> 単価、数量が共に空白でないなら金額表示 display "@FLENGTH|/*QTY" accept qflen display "@FLENGTH|/*UTANKA" accept tflen if tflen not = 0 and qflen not = 0 display "@GET|/*QTY" accept qty display "@GET|/*UTANKA" accept utanka compute ukingaku = qty * utanka if ukingaku > 9999999 display "ALARM|0|0|数量が大きすぎます。" display "CLEAR|/*UKIN" display "POSITION|/*QTY" else move ukingaku to fld-kin display "PUT|/*UKIN|" fld-kin end-if *> 単価、数量のいずれかが空白なら金額クリア else display "CLEAR|/*UKIN" end-if. *>---------------------------------------------------------------- 仕入金額更新 section. *>---------------------------------------------------------------- *> 単価、数量が共に空白でないなら金額表示 display "@FLENGTH|/*QTY" accept qflen display "@FLENGT|/*STANKA" accept tflen if tflen not = 0 and qflen not = 0 display "@GET|/*QTY" accept qty display "@GET|/*STANKA" accept stanka compute skingaku = qty * stanka if skingaku > 9999999 display "ALARM|0|0|数量が大きすぎます。" display "CLEAR|/*SKIN" display "POSITION|/*QTY" else move skingaku to fld-kin display "PUT|/*SKIN|" fld-kin end-if *> 単価、数量のいずれかが空白なら金額クリア else display "CLEAR|/*SKIN" end-if. *>---------------------------------------------------------------- ファイル出力 section. *>---------------------------------------------------------------- *> アイテム部データの取得 *> (配列フィールドをループ処理によって順次アクセスする例) perform varying arno from 1 by 1 until arno > 5 display "@GET|QTY" arno accept item-qty(arno) display "@GET|UTANKA" arno accept item-utnk(arno) display "@GET|STANKA" arno accept item-stnk(arno) *> ---- 以下同様(中略) ---- end-perform *>------------------------------ *> ファイル出力処理(省略) *>------------------------------ display "ALARM|23|6|ファイルに書き込みました。" display "POSITION|/HOME" display "CLEAR|/ALL" display "PUT|DVCODE|" den-no display "DATESET|DATE". *>---------------------------------------------------------------- 行シフト section. *>---------------------------------------------------------------- *> カレントフィールドの処理コードでアイテム部に居る事を判断し、 *> アイテム行のプッシュ、ポップを実行する display "@CODE|/CUR" accept field-code if field-code = "S" or = "Q" or = "I" or = "U" or = "N" display shift-cmd "|/*SVCODE|/E" display shift-cmd "|/*SVNAME|/E" display shift-cmd "|/*QTY|/E" display shift-cmd "|/*UTANKA|/E" display shift-cmd "|/*UKIN|/E" display shift-cmd "|/*STANKA|/E" display shift-cmd "|/*SKIN|/E" end-if. *>---------------------------------------------------------------- 得意先一覧 section. *>---------------------------------------------------------------- *> 得意先ウィンドウ表示 *> TVLB.SCRのリストボックスにはデータファイル名が定義されており、 *> 画面表示を指示するだけでデータが自動的にロードされます。 *> これは iii/Winによるリストボックスの機能拡張の一つです。 display "WINDOW|TVLB.SCR" *> 選択処理 放棄終了:イベント111 = [ESC]キー、取り消しボタン *> 選択決定:イベント210 = LIST BOX選択 *> 190 = 確定ボタン display "SET|LB_SELECTNO|LB1|1" display "@INPUT|/EVENT" accept eventno *> LIST BOXとのデータの授受はフィールド単位で行なえますので *> 非常に取り扱いが便利です。 *> これも iii/Winによるリストボックスの機能拡張の一つの例です。 if eventno not = 111 display "@QUERY|LB_SELECTNO|LB1" accept lnno display "@GET|TVCODE" lnno accept 得意コード display "@GET|TVNAME" lnno accept 得意先名 end-if *> 親画面に戻り、選択された得意先を表示 display "RESTORE" if eventno not = 111 display "CLEAR|TVADR" display "PUT|TVCODE|" 得意コード display "PUT|TVNAME|" 得意先名 end-if. *>---------------------------------------------------------------- 商品一覧 section. *>---------------------------------------------------------------- display "@CODE|/CUR" accept field-code if field-code = "S" or = "Q" or = "I" or = "U" or = "N" perform 商品一覧処理 else display "ALARM|23|6|商品選択は明細行で行なって下さい。" end-if. *>---------------------------------------------------------------- 商品一覧処理 section. *>---------------------------------------------------------------- *> 商品ウィンドウ表示。データは自動的にロードされます。 display "WINDOW|SVLB.SCR" *> 選択処理 放棄終了:イベント111 = [ESC]キー、取り消しボタン *> 選択決定:イベント210 = LIST BOX選択 *> 190 = 確定ボタン display "SET|LB_SELECTNO|LB1|1" display "@INPUT|/EVENT" accept eventno *> LIST BOXとのデータの授受。フィールド単位で行なえます。 if eventno not = 111 display "@QUERY|LB_SELECTNO|LB1" accept lnno display "@GET|SVCODE" lnno accept 商品コード display "@GET|SVNAME" lnno accept 商品名 display "@GET|UTANKA" lnno accept 販売単価 display "@GET|STANKA" lnno accept 仕入単価 end-if *> 親画面に戻り、選択された商品をカーソル位置の行に表示 display "RESTORE" if eventno not = 111 display "CLEAR|/*UKIN" display "CLEAR|/*SKIN" display "CLEAR|/*QTY" display "PUT|/*SVCODE|" 商品コード display "PUT|/*SVNAME|" 商品名 display "PUT|/*UTANKA|" 販売単価 display "PUT|/*STANKA|" 仕入単価 display "POSITION|/*QTY" end-if. *>---------------------------------------------------------------- 印刷処理 section. *>---------------------------------------------------------------- *> ウィンドウ表示 display "WINDOW|URIPRN.SCR" display "PUT|C01|1" display "PUT|R02|1" display "PUT|R03|1" *> 入力と指定処理 :イベント 111 =放棄終了ボタンと [ESC]キー *> イベント 101 =印刷実行ボタン perform with test after until eventno = 111 display "@INPUT|/NEXT" accept eventno if eventno = 101 display "@FLENGTH|F01" accept qflen display "@FLENGTH|F02" accept tflen if qflen=0 or tflen=0 display "ERROR|0|0|開始と終了番号を入力して下さい。" else display "ERROR|0|0|サンプルにつき実際の印刷はできません" end-if end-if end-perform display "RESTORE".