home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / memacs32.zip / opage.cmd < prev    next >
OS/2 REXX Batch file  |  1993-08-07  |  6KB  |  248 lines

  1. ;    OPAGE.CMD:    COBOL language MENU Page
  2. ;            for MicroEMACS 3.11 and above
  3. ;            (C)opyright 1988 by Daniel Lawrence
  4. ;
  5.  
  6. ; set up the "clean" procedure
  7. store-procedure clean
  8.     delete-buffer "[Macro 10]"
  9.     delete-buffer "[Macro 11]"
  10.     delete-buffer "[Macro 12]"
  11.     delete-buffer "[Macro 13]"
  12.     delete-buffer "[Macro 14]"
  13.     delete-buffer "[Macro 15]"
  14.     delete-buffer "[Macro 16]"
  15.     delete-buffer "[Macro 17]"
  16.     delete-buffer "[Macro 18]"
  17.     delete-buffer "[Macro 19]"
  18.     bind-to-key handle-tab ^I
  19.     delete-buffer "[cobol-tab]"
  20.     set $cmode %oldmode
  21.     set $gmode %oldgmode
  22.     0 handle-tab
  23. !endm
  24.  
  25. ; make sure the function key window is up
  26.     set %rcfkeys FALSE
  27.     toggle-fkeys
  28.     write-message "Loading..."
  29.  
  30. ; Write out the page instructions
  31.     save-window
  32.     1 next-window
  33.     beginning-of-file
  34.     set $curcol 25
  35.     overwrite-string " F1 Make IDENT division   F2 UPPERcase buffer   "
  36.     next-line
  37.     set $curcol 25
  38.     overwrite-string " F3 Make ENVIR division   F4 while              "
  39.     next-line
  40.     set $curcol 25
  41.     overwrite-string " F5 REPEAT                F6 switch             "
  42.     next-line
  43.     set $curcol 18
  44.     overwrite-string "COBL"
  45.     set $curcol 25
  46.     overwrite-string " F7 VALUE                 F8 Reserved words UP  "
  47.     next-line
  48.     set $curcol 25
  49.     overwrite-string " F9 chk comment matching F10 Shell to DOS       "
  50.     unmark-buffer
  51.     beginning-of-file
  52.     !force restore-window
  53.     update-screen
  54.  
  55. ;
  56.  
  57. 10    store-macro
  58.     beginning-of-file
  59.  
  60.     set %rctemp @"Program Name: "
  61.     insert-string "       IDENTIFICATION DIVISION.~n"
  62.     insert-string &cat &cat "       PROGRAM-ID. " %rctemp ".~n"
  63.     update-screen
  64.     set %rctemp @"Author: "
  65.     insert-string &cat &cat "       AUTHOR. " %rctemp ".~n"
  66.     insert-string &cat &cat "       DATE-WRITTEN. " $time ".~n"
  67.     insert-string "       DATE-COMPILED.~n"
  68.     insert-string "       REMARKS.~n~n"
  69. !endm
  70. bind-to-key execute-macro-10 S-FN1
  71.  
  72. ;    Function
  73. 11    store-macro
  74.     9 set-mark
  75.     beginning-of-file
  76.     set-mark
  77.     end-of-file
  78.     case-region-upper
  79.     9 goto-mark
  80. !endm
  81. bind-to-key execute-macro-11 S-FN2
  82.  
  83. ;
  84.  
  85. 12    store-macro
  86.     insert-string "       ENVIRONMENT DIVISION.~n"
  87.     insert-string "       CONFIGURATION SECTION.~n"
  88.     insert-string "       SOURCE-COMPUTER. IBM-3090.~n"
  89.     insert-string "       OBJECT-COMPUTER. IBM-3090.~n"
  90.     insert-string "       SPECIAL-NAMES.~n"
  91.     insert-string "       INPUT-OUTPUT SECTION.~n"
  92.     insert-string "       FILE-CONTROL.~n"
  93. !endm
  94. bind-to-key execute-macro-12 S-FN3
  95.  
  96. ;
  97.  
  98. 13    store-macro
  99.         set %cond @"Condition Expr: "
  100.     ;set $debug TRUE
  101.         insert-string &cat &cat "while (" %cond ") {"
  102.     newline-and-indent
  103.     newline-and-indent
  104.         insert-string &cat &cat "}  /* while (" %cond ") */"
  105.     1 previous-line
  106.         end-of-line
  107.     handle-tab
  108. !endm
  109. bind-to-key execute-macro-13 S-FN4
  110.  
  111. 14    store-macro
  112.         set %cond @"Condition Expr: "
  113.     ;set $debug TRUE
  114.         set %curcol $curcol
  115.         insert-string &cat &cat "REPEAT~n"
  116.         %curcol insert-string " "
  117.         set $curcol %curcol
  118.         !if &EQUal  %curcol 3
  119.             insert-string &cat &cat "UNTIL " %cond ";"
  120.     !else
  121.             insert-string &cat      "UNTIL " %cond 
  122.     !endif
  123.         beginning-of-line
  124.         open-line
  125.         %curcol insert-string " "
  126.         insert-string "   "
  127.     !force set $debug FALSE
  128. !endm
  129. bind-to-key execute-macro-14 S-FN5
  130.  
  131. 15    store-macro
  132.         set %expr @"Switch Expr: "
  133.     ;set $debug TRUE
  134.         set %curcol $curcol
  135.         insert-string &cat &cat "switch (" %expr ") {"
  136.     newline-and-indent
  137.     insert-string "}"
  138.     previous-line
  139.     end-of-line
  140.     newline-and-indent
  141.     handle-tab
  142.     insert-string "case "
  143.     !force set $debug FALSE
  144. !endm
  145. bind-to-key execute-macro-15 S-FN6
  146.  
  147. 16    store-macro
  148. ;    set $debug TRUE
  149.         set %curcol $curcol
  150.         set %value @"Value: "
  151.         insert-string &cat %value " : {~n"
  152.         %curcol insert-string " "
  153.         insert-string "    };~n"
  154.         %curcol insert-string " "
  155.     previous-line
  156.         beginning-of-line
  157.         open-line
  158.         %curcol insert-string " "
  159.         insert-string "       "
  160.     !force set $debug FALSE
  161. !endm
  162. bind-to-key execute-macro-16 S-FN7
  163.  
  164. 17    store-macro
  165. ;    set $debug TRUE
  166.         set %curcol $curcol
  167.     ;save-file
  168.         set-mark
  169.     beginning-of-file
  170.         write-message "[Replacing 'begin']
  171.     replace-string "begin" "BEGIN"
  172.  
  173.     beginning-of-file
  174.         write-message "[Replacing 'end']
  175.     replace-string "end" "END"
  176.  
  177.     beginning-of-file
  178.         write-message "[Replacing ' if']
  179.     replace-string " if" " IF"
  180.  
  181.     beginning-of-file
  182.         write-message "[Replacing ' else']
  183.     replace-string " else" " ELSE"
  184.  
  185.     beginning-of-file
  186.         write-message "[Replacing ' repeat']
  187.     replace-string " repeat" " REPEAT"
  188.  
  189.     beginning-of-file
  190.         write-message "[Replacing ' while']
  191.     replace-string " while" " WHILE"
  192.  
  193.         exchange-point-and-mark
  194.     !force set $debug FALSE
  195. !endm
  196. bind-to-key execute-macro-17 S-FN8
  197.  
  198. 18    store-macro
  199.     beginning-of-file
  200.     source findcom.cmd
  201. !endm
  202. bind-to-key execute-macro-18 S-FN9
  203.  
  204. 19    store-macro
  205.     i-shell
  206. !endm
  207. bind-to-key execute-macro-19 S-FN0
  208.  
  209. ;    This macro assumes we are on an 01 entry line and
  210. ;    moves all the datanames to the DATANAMES buffer
  211.  
  212. store-procedure getrecnames
  213.     set %orbuf $cbufname
  214.     !force delete-buffer DATANAMES
  215.     9 set-mark
  216. *grn    beginning-of-line
  217.     next-line
  218.     8 forward-character
  219.     !if ¬ &equ $curchar 32 
  220.         9 goto-mark
  221.         write-message "[data names recorded]"
  222.         !return
  223.     !endif
  224.  
  225. !endm
  226.  
  227. ; modify the tabbing behavior to match COBOL
  228.  
  229. store-procedure    cobol-tab
  230.     !if &less $curcol 7
  231.         set %rctmp &sub 7 $curcol
  232.     !else
  233.         set %rctmp &sub &add 3 &band 252 &add 1 $curcol $curcol
  234.     !endif
  235.     %rctmp insert-space
  236.     %rctmp forward-character
  237. !endm
  238. macro-to-key cobol-tab ^I
  239.  
  240. ; Set up CMODE
  241.     set %oldmode $cmode
  242.     set %oldgmode $gmode
  243.     add-mode CMODE
  244.     add-global-mode CMODE
  245.     4 handle-tab
  246.  
  247. write-message "[COBOL MENU page loaded]"
  248.