home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rc321.zip / rexxcc2.cmd < prev    next >
OS/2 REXX Batch file  |  1997-09-28  |  130KB  |  3,271 lines

  1. /* ------------------------------------------------------------------ */
  2. /* REXXCC2.CMD - simple WPS front end for REXXCC.CMD v3.00 and above  */
  3. /*                                                                    */
  4. /* (c) 1995 - 1997 Bernd Schemmer                                     */
  5. /*                                                                    */
  6. /* Author:                                                            */
  7. /*   Bernd Schemmer                                                   */
  8. /*   Baeckerweg 48                                                    */
  9. /*   D-60316 Frankfurt                                                */
  10. /*   Germany                                                          */
  11. /*   CompuServe: 100104,613                                           */
  12. /*                                                                    */
  13. /* Initial Release:                                                   */
  14. /*   18.05.1995 /bs                                                   */
  15. /* Last Update:                                                       */
  16. /*   01.06.1995 /bs v1.00                                             */
  17. /*     - version 1.00                                                 */
  18. /*   15.06.1995 /bs v1.01                                             */
  19. /*     - use TIMEOUT events for the compile status window             */
  20. /*   25.10.1995 /bs v1.10                                             */
  21. /*     - added the support for the new REXXCC parameter /CMode and    */
  22. /*     - /ShowDate                                                    */
  23. /*                                                                    */
  24. /* Usage:                                                             */
  25. /*  {RX} REXXCC2                                                      */
  26. /*                                                                    */
  27. /* Parameters:                                                        */
  28. /*   *** no parameter possible for programs running under RX ***      */
  29. /*                                                                    */
  30. /* Note:                                                              */
  31. /*   The prefix 'RX' is possible but not neccessary, you should only  */
  32. /*   use it if you create an object for REXXCC/2 (see install.cmd).   */
  33. /*                                                                    */
  34. /*   This program needs the OS/2 REXX dll REXXUTIL and                */
  35. /*   the "Rexx Dialog" package.                                       */
  36. /*                                                                    */
  37. /*   CAUTION: The documentation for "Rexx Dialog" states that there   */
  38. /*            should be a DLL called RX.DLL. This is a typo!          */
  39. /*            "Rexx Dialog" consists out of the file RX.EXE and       */
  40. /*            RXDLG.DLL.                                              */
  41. /*                                                                    */
  42. /*   "Rexx Dialog" is an excellent REXX extension for using PM        */
  43. /*   dialogs in REXX programs developed by Jeff Glatt.                */
  44. /*   "Rexx Dialog" is distributed as freeware.                        */
  45. /*   The neccessary parts of this package are included in the         */
  46. /*   archiv containing this program.                                  */
  47. /*   You may view RX.INF, the online help for "Rexx Dialog", for      */
  48. /*   further information about using "Rexx Dialog".                   */
  49. /*   You can get the original "Rexx Dialog" package from your         */
  50. /*   favorite BBS or CompuServe (GO OS2DF1, Libary 6).                */
  51. /*   The name of the archiv is RXDLG10.ZIP.                           */
  52. /*   Again, "Rexx Dialog" is a real good work. Thanks Jeff.           */
  53. /*                                                                    */
  54. /*   See the file REXXCC.CMD for further information about the        */
  55. /*   "compiler" REXXCC.CMD.                                           */
  56. /*                                                                    */
  57. /*   Workarounds for bugs (well, I think that are bugs) in            */
  58. /*   Rexx Dialog 1.0 are marked with (*?*)                            */
  59. /*                                                                    */
  60. /*   REXXCC/2 saves it configuration in an ini file called            */
  61. /*   REXXCC2.INI. The search algorithm for this file is:              */
  62. /*        1. search in the current directory                          */
  63. /*        2. if not found: search in the DPATH directorys             */
  64. /*        3. if not found: search in the directory with               */
  65. /*           REXXCC2.CMD                                              */
  66. /*        4. if not found: use defaults (don't load an inifile)       */
  67. /*                                                                    */
  68. /* Hints:                                                             */
  69. /*                                                                    */
  70. /*   IMPORTANT: YOU CAN ONLY USE A PM EDITOR FROM WITHIN REXXCC/2!!!  */
  71. /*                                                                    */
  72. /*   The keyboard handling in version 1.0 of Rexx Dialog is limited   */
  73. /*   and has some minor bugs. So avoid using the keyboard to change   */
  74. /*   the active dialog element.                                       */
  75. /*                                                                    */
  76. /*   If your WPS seems to lockup while using REXXCC/2 hit CTRL-ESC    */
  77. /*   several times and wait at least 30 seconds. Normally OS/2 will   */
  78. /*   then popup a dialog to allow aborting REXXCC/2.                  */
  79. /*                                                                    */
  80. /* Developed for using on 1024*768 display sizes but works also in    */
  81. /* the resolution 800*600. I haven't tested it in VGA resolution      */
  82. /* because I think it's silly to use OS/2 in VGA mode.                */
  83. /* For display resolutions higher than 1024*768 you must change the   */
  84. /* window dimensions and the control positions & sizes in the         */
  85. /* source code yourself.                                              */
  86. /*                                                                    */
  87. /* Distribution                                                       */
  88. /*   This program is part of the REXXCC package. Please see the file  */
  89. /*   REXXCC.CMD for my distribution policy.                           */
  90. /*   See the file RX.INF for the using & distribution policy for      */
  91. /*   Rexx Dialog.                                                     */
  92. /* ------------------------------------------------------------------ */
  93.  
  94.                         /* init some global variables                 */
  95.   parse upper source . . prog.__FullName
  96.  
  97.   prog.__name = fileSpec( 'N', prog.__FullName )
  98.  
  99.   prog.__Path = fileSpec( 'D', prog.__FullName ) || ,
  100.                 fileSpec( 'P', prog.__FullName )
  101.                     /* prog.__Path should never end with a backslash  */
  102.   if right( prog.__Path,1 ) = '\' then
  103.     prog.__Path = dbrright( prog.__Path,1 )
  104.  
  105.                         /* OS/2 environment                           */
  106.   prog.__env = 'OS2ENVIRONMENT'
  107.  
  108.                         /* version of REXXCC/2                        */
  109.   prog.__Version = 'v1.10'
  110.  
  111.                         /* version of the inifile                     */
  112.   prog.__IniFileVersion = 'v1.00'
  113.  
  114.                         /* name of REXXCC/2 for the dialogs           */
  115.   prog.__vName = 'REXXCC/2'
  116.  
  117.                         /* copyright note                             */
  118.   prog.__vCopyright = '(c) Bernd Schemmer 1997'
  119.  
  120.                         /* program exit code                          */
  121.   prog.__ExitCode = 255
  122.  
  123.                         /* name for the inifile                       */
  124.   prog.__IniFileName = 'REXXCC2.INI'
  125.  
  126.                         /* name of the stems all procedures must know */
  127.   exposeList = 'prog. global. REXXCC. REXXCC2. window. CRLF'
  128.  
  129.                         /* ASCII codes for CR/LF                      */
  130.   CRLF = '0D0A'x
  131.  
  132.  
  133. /* ------------------------------------------------------------------ */
  134.                         /* load the DLL REXXUTIL                      */
  135.                         /* (we need REXXUTIL for searching RX.EXE     */
  136.   if LoadRexxUtil() <> 1 then
  137.   do
  138.     say prog.__Name || ,
  139.         '- Error: Can not load REXXUTIL!' || '07'x
  140.     exit 255
  141.   end /* if LoadRexxUtil() <> 1 then */
  142.  
  143. /* ------------------------------------------------------------------ */
  144.                         /* check the address environment              */
  145.   if address() <> 'RXDLG' then
  146.   do
  147.                         /* THIS part is only executed if NOT running  */
  148.                         /* under RXDLG!                               */
  149.  
  150.                         /* not currently running under RX             */
  151.  
  152.                         /* check for parameter                        */
  153.     parse arg thisParms
  154.     if thisParms <> '' then
  155.     do
  156.                         /* parameter are not possible for programs    */
  157.                         /* running under "Rexx Dialog"                */
  158.       say 'Usage: {RX} 'prog.__Name
  159.       exit 2
  160.     end /* if thisParms <> '' then */
  161.  
  162.                         /* search RX.EXE                              */
  163.     prog.__RX =  SearchProgram( 'RX.EXE' )
  164.     if prog.__RX = '' then
  165.     do
  166.                         /* RX.EXE not found                           */
  167.       say prog.__Name || ,
  168.           '- Error: Can not find RX.EXE!' || '07'x
  169.       exit prog.__ExitCode
  170.     end /* if SearchProgram( 'RX.EXE' ) = '' then */
  171.     else
  172.     do
  173.                         /* RX.EXE found -- call it with this file as  */
  174.                         /* parameter.                                 */
  175.       ADDRESS 'CMD' '@' || prog.__RX prog.__FullName
  176.       exit rc
  177.     end /* else */
  178.   end /* if adress() <> 'RXDLG' then */
  179.  
  180. /* ------------------------------------------------------------------ */
  181.                         /* the ADDRESS environment is okay --         */
  182.                         /* already running under RX.EXE               */
  183.  
  184. /* ------------------------------------------------------------------ */
  185.                         /* install error handler(s)                   */
  186.   SIGNAL ON NOVALUE Name NoValue
  187.  
  188. /* ------------------------------------------------------------------ */
  189.                         /* init the global data                       */
  190.   call InitVariables
  191.  
  192.                         /* init the data for Rexx Dialog              */
  193.   call InitRxDlg
  194.  
  195. /* ------------------------------------------------------------------ */
  196.                         /* check if RXQUEUE is in one of the PATH     */
  197.                         /* directorys                                 */
  198.   if SearchProgram( 'RXQUEUE.*' ) = '' then
  199.   do
  200.     call ShowErrorMsg , 'Can not find the program RXQUEUE. ' || crlf ,
  201.                         'Ensure that RXQUEUE is in one of the PATH directorys.'
  202.     exit 255
  203.   end /* if SearchProgram( ... */
  204.  
  205. /* ------------------------------------------------------------------ */
  206.                         /* search the ini file                        */
  207.   curIniFileName = ''   /* default: no inifile found                  */
  208.  
  209.                         /* show a status msg                          */
  210.   call ShowStatusMsg 'OPEN', 'Searching an ini file ...'
  211.  
  212.                         /* update the status msg                      */
  213.   call ShowStatusMsg 'UPDATE', '=' '00'x 'Searching in the current directory ... '
  214.  
  215.                         /* search in the current directory            */
  216.   if FileExist( directory() || '\' || prog.__IniFileName ) <> 0 then
  217.     curIniFileName = directory() || '\' || prog.__IniFileName
  218.  
  219.                         /* update the status msg                      */
  220.   call ShowStatusMsg 'UPDATE', '=' '00'x 'Searching the directorys in the DPATH ...'
  221.  
  222.                         /* search in the DPATH directorys             */
  223.   if curIniFileName = '' then
  224.     curIniFileName = SearchDataFile( prog.__IniFileName )
  225.  
  226.                         /* search in the directory with REXXCC.CMD    */
  227.   if curIniFileName = '' then
  228.   do
  229.                         /* update the status msg                      */
  230.     call ShowStatusMsg 'UPDATE', '=' '00'x 'Searching the directory with REXXCC2.CMD ... '
  231.  
  232.     if FileExist( prog.__Path || '\' || prog.__IniFileName ) <> 0 then
  233.       curIniFileName = prog.__Path || '\' || prog.__IniFileName
  234.   end /* if curIniFileName = '' then */
  235.  
  236.                         /* load the infile if found                   */
  237.   if curIniFileName <> '' then
  238.     call LoadSaveConfigData 'LOAD', curIniFileName
  239.   else                  /* close the status msg                       */
  240.     call ShowStatusMsg 'CLOSE'
  241.  
  242.  
  243. /* ------------------------------------------------------------------ */
  244.                         /* setup the variables for the main dialog    */
  245.  
  246.                         /* main dialog title                          */
  247.   MainWindowTitle = prog.__vName prog.__Version prog.__vCopyright
  248.  
  249.                         /* groups & fields for the main dialog        */
  250.   i = 0
  251.  
  252.                         /* drop down box for the source file          */
  253.   i = i+1                       ; md.__SourceFileDropBox = i
  254.   RXTYPE.i  = 'DROP'
  255.   RXFLAGS.i = ' '
  256.   RXLABEL.i = 'SourceFile:'
  257.   RXINFO.i  = '1 1 1000'
  258.   RXVAL.i   = 'sourceFiles'
  259.   RXX.i     = 120
  260.   RXY.i     = 245
  261.  
  262.                         /* drop down box for the target file          */
  263.   i = i+1                       ; md.__TargetFileDropBox = i
  264.   RXTYPE.i  = 'DROP'
  265.   RXFLAGS.i = ' '
  266.   RXLABEL.i = 'TargetFile:'
  267.   RXINFO.i  = '1 1 1000'
  268.   RXVAL.i   = 'targetFiles'
  269.   RXX.i     = 120
  270.   RXY.i     = 218
  271.  
  272.                         /* drop down box for the copyright file       */
  273.   i = i+1                       ; md.__CopyrightFileDropBox = i
  274.   RXTYPE.i  = 'DROP'
  275.   RXFLAGS.i = ' '
  276.   RXLABEL.i = 'CopyrightFile:'
  277.   RXINFO.i  = '1 1 1000'
  278.   RXVAL.i   = 'copyrightFiles'
  279.   RXX.i     = 120
  280.   RXY.i     = 191
  281.  
  282.                         /* push buttons for the file dialogs          */
  283.   i=i+1                         ; md.__SourceTargetCopyrightPushButtons = i
  284.   RXTYPE.i  = 'PUSH'
  285.   RXFLAGS.i = 'END'
  286.   RXLABEL.i = 'Search | Search | Search '
  287.   RXINFO.i  = '3 1 0'
  288.   RXVAL.i   = '1'
  289.   RXX.i     = 365
  290.   RXY.i     = 185
  291.  
  292.         /* push buttons for the misc. action on the s/t/c files       */
  293.   i=i+1                         ; md.__MiscActionPushButtons = i
  294.   RXTYPE.i  = 'PUSH'
  295.   RXFLAGS.i = 'END'
  296.   RXLABEL.i = ' Edit copyrightFile | Use default targetDir | Create Tokenimage '
  297.   RXINFO.i  = '3 1 200'
  298.   RXVAL.i   = '1'
  299.   RXX.i     = 445
  300.   RXY.i     = 185
  301.  
  302.                         /* radio buttons for the mode of REXXCC       */
  303.   i=i+1                         ; md.__ModeRadioButtons = i
  304.   RXTYPE.i  = 'RADIO'
  305.   RXFLAGS.i = 'END'
  306.   RXLABEL.i = 'Compress | Compile | Mode'
  307.   RXINFO.i  = '2 1 0'
  308.   RXVAL.i   = REXXCC.__Mode
  309.   RXX.i     = 505
  310.   RXY.i     = 75
  311.  
  312.                         /* check boxes for the REXXCC options         */
  313.   i=i+1                         ; md.__OptionCheckBoxes = i
  314.   RXTYPE.i  = 'CHECK'
  315.   RXFLAGS.i = ' '
  316.   RXLABEL.i = 'Add Code | Ignore Date | Ignore Version | Ignore Extension | ',
  317.               'Overwrite | Use Source | Use CMode | ShowDate | REXXCC Options '
  318.   RXINFO.i  = '8 2 0'
  319.   RXVAL.i   = REXXCC.__Options
  320.   RXX.i     = 15
  321.   RXY.i     = 50
  322.  
  323.                         /* push buttons for the actions               */
  324.   i=i+1                         ; md.__ActionPushButtons = i
  325.   RXTYPE.i  = 'PUSH'
  326.   RXFLAGS.i = 'END'
  327.   RXLABEL.i = 'Exit | Reset | Options '
  328.   RXINFO.i  = '3 3 0'
  329.   RXVAL.i   = '3'
  330.   RXX.i     = 130
  331.   RXY.i     = 5
  332.  
  333.                         /* push buttons for compiling                 */
  334.   i=i+1                         ; md.__CompilePushButton = i
  335.   RXTYPE.i  = 'PUSH'
  336.   RXFLAGS.i = 'END'
  337.   RXLABEL.i = 'Compile'
  338.   RXINFO.i  = '1 1 0'
  339.   RXVAL.i   = '1'
  340.   RXX.i     = 370
  341.   RXY.i     = 5
  342.  
  343.                         /* push buttons for compressing               */
  344.   i=i+1                         ; md.__CompressPushButton = i
  345.   RXTYPE.i  = 'PUSH'
  346.   RXFLAGS.i = 'END'
  347.   RXLABEL.i = 'Compress'
  348.   RXINFO.i  = '1 1 0'
  349.   RXVAL.i   = '1'
  350.   RXX.i     = 370
  351.   RXY.i     = 5
  352.  
  353.                         /* spin control for the linecount value       */
  354.   i=i+1                         ; md.__LineCountSpin = i
  355.   RXTYPE.i  = 'SPIN'
  356.   RXFLAGS.i = ' '
  357.   RXLABEL.i = '255 0 Linecount:'
  358.   RXINFO.i  = '1 1 60'
  359.   RXVAL.i   = REXXCC.__LineCount
  360.   RXX.i     = 430
  361.   RXY.i     = 120
  362.  
  363.                         /* push button for about                      */
  364.   i=i+1                         ; md.__AboutPushButtons = i
  365.   RXTYPE.i  = 'PUSH'
  366.   RXFLAGS.i = 'END'
  367.   RXLABEL.i = 'About'
  368.   RXINFO.i  = '1 1 0'
  369.   RXVAL.i   = '1'
  370.   RXX.i     = 535
  371.   RXY.i     = 5
  372.  
  373.                         /* no. of groups in the main window           */
  374.   noOfGroupsInMainWIn = i
  375.  
  376. /* ------------------------------------------------------------------ */
  377.  
  378.                         /* main program loop                          */
  379.   do forever
  380.                         /* check if the main window is already open   */
  381.     RxQuery '"'mainWindowTitle'"'
  382.     if rc = 0 then
  383.     do
  384.                     /* main window not yet open -> show the dialog    */
  385.       RxDlg noOfGroupsInMainWin  ,  /* no. of groups                  */
  386.             '"'mainWindowTitle'"',  /* window Title                   */
  387.             'WINDOW.__MAINWINDOWDIM'  , /* dimension                  */
  388.             'NOCLOSE|RESULT|KEYS'   /* flags, possible values:        */
  389.                                     /* SIZE MIN SMALL MODAL NOCLOSE   */
  390.                                     /* RESULT KEYS ONE NEWSIZE        */
  391.  
  392.  
  393.                                     /* update the entry fields of the */
  394.                                     /* drop down boxes                */
  395.       if sourceFiles.0 <> '' then
  396.         RxSet '"'MainWindowTitle'"' md.__SourceFileDropBox 1 'VAL' sourceFiles.0
  397.  
  398.       if targetFiles.0 <> '' then
  399.         RxSet '"'MainWindowTitle'"' md.__TargetFiledropBox 1 'VAL' targetFiles.0
  400.  
  401.       if copyrightFiles.0 <> '' then
  402.         RxSet '"'MainWindowTitle'"' md.__CopyrightFileDropBox 1 'VAL' copyrightFiles.0
  403.  
  404.     end /* if rc = 0 then */
  405.  
  406.                                     /* show the correct action button */
  407.                                     /* (compile or compress)          */
  408.     if value( 'RXVAL.' || md.__ModeRadioButtons ) = 2 then
  409.     do
  410.       RxSet '"'MainWindowTitle'"' md.__CompressPushButton 1 'HIDE' 0
  411.       RxSet '"'MainWindowTitle'"' md.__CompilePushButton  1 'SHOW' 0
  412.     end /* if */
  413.     else
  414.     do
  415.       RxSet '"'MainWindowTitle'"' md.__CompilePushButton  1 'HIDE' 1
  416.       RxSet '"'MainWindowTitle'"' md.__CompressPushButton 1 'SHOW' 0
  417.     end /* else */
  418.  
  419.                         /* perform user actions                       */
  420.     RxDlg '"'mainWindowTitle'"' 0
  421.  
  422.                         /* update REXX variables                      */
  423.     RxDlg '"'mainWindowTitle'"' 2
  424.  
  425.                         /* clear the PM message queue                 */
  426.     RxDlg '""' 255
  427.  
  428.                         /* process the RxDlg return code              */
  429.  
  430.     /* ------------------ alt keycode processing -------------------- */
  431.     /* (*) neccessary, because accelerator keys are not handled in    */
  432.     /*     the version 1.0 of Rexx Dialog                             */
  433.  
  434.     select
  435.  
  436.       when rxID = -1 then
  437.       do
  438.                         /* ALT-letter pressed                         */
  439.  
  440.                         /* rxSubID = letter                           */
  441.         rxSubId = translate( rxSubID )
  442.  
  443.         possibleKeys    = 'S T C E R O M A X'
  444.         rxIDsForKeys    = md.__SourceTargetCopyrightPushButtons ,
  445.                           md.__SourceTargetCopyrightPushButtons ,
  446.                           md.__SourceTargetCopyrightPushButtons ,
  447.                           md.__ActionPushButtons ,
  448.                           md.__ActionPushButtons ,
  449.                           md.__ActionPushButtons ,
  450.                           md.__ActionPushButtons ,
  451.                           md.__AboutPushButtons ,
  452.                           md.__ActionPushButtons
  453.         rxSubIDsForKeys = '3 2 1 1 2 3 4 1 1'
  454.  
  455.         i = wordPos( rxSubId, possibleKeys )
  456.         if i <> 0 then
  457.         do
  458.                         /* change the rxID & the rxSubID to the IDs   */
  459.                         /* for the dialog element using this hotkey   */
  460.           rxID = word( rxIDsForKeys, i )
  461.           rxSubID = word( rxSubIDsForKeys, i )
  462.         end /* if i <> 0 then */
  463.       end /* if */
  464.  
  465.       otherwise
  466.         nop
  467.     end /* select */
  468.  
  469.  
  470.     select
  471.       /* ------------------ time out action ------------------------- */
  472.       when rxID = 0 & rxSubID = 0 then
  473.       do
  474.                         /* timeout occured                            */
  475.       end /* when */
  476.  
  477.       /* ------------------ key pressed action ---------------------- */
  478.       when rxID < 0 & rxID > -11 then
  479.       do
  480.       end /* when */
  481.  
  482.       /* ------------------ ESC pressed ----------------------------- */
  483.       when rxID = -12 then
  484.       do
  485.                         /* set the program return code                */
  486.         prog.__ExitCode = 1
  487.  
  488.         leave
  489.       end /* when */
  490.  
  491.       /* ------------------ window resized -------------------------- */
  492.       when rxID = -20 then
  493.       do
  494.       end /* when */
  495.  
  496.       /* ------------------ CLOSE ICON used ------------------------- */
  497.       when rxID = -98 then
  498.       do
  499.                     /* exit REXXCC2 without saving the configuration! */
  500.  
  501.                         /* set the program return code                */
  502.         prog.__ExitCode = 1
  503.  
  504.         leave
  505.       end /* when */
  506.  
  507.       /* ------------------ abort forced by another application ----- */
  508.       when rxID = -99 then
  509.       do
  510.                     /* exit REXXCC2 without saving the configuration! */
  511.  
  512.                         /* set the program return code                */
  513.         prog.__ExitCode = 1
  514.  
  515.         leave
  516.       end /* when */
  517.  
  518.       /* ------------------ unknown action occured ------------------ */
  519.       when rxID < 0 then
  520.       do
  521.                     /* exit REXXCC2 without saving the configuration! */
  522.                         /* set the program return code                */
  523.         prog.__ExitCode = 254
  524.  
  525.         leave
  526.       end /* when */
  527.  
  528.       /* ------------------------------------------------------------ */
  529.                         /* if we come to this point,                  */
  530.                         /* RXID contains the group no.                */
  531.  
  532.       /* ------------------ sourcefile drop down box ---------------- */
  533.       when rxID = md.__SourceFileDropBox then
  534.       do
  535.       end /* when */
  536.  
  537.       /* ------------------ target file drop down box --------------- */
  538.       when rxID = md.__TargetFileDropBox then
  539.       do
  540.       end /* when */
  541.  
  542.       /* ------------------ copyright box drop down box ------------- */
  543.       when rxID = md.__CopyrightFileDropBox then
  544.       do
  545.       end /* when */
  546.  
  547.       /* ------------------ search push buttons --------------------- */
  548.       when rxID = md.__SourceTargetCopyrightPushButtons then
  549.       do
  550.  
  551.         select
  552.  
  553.           /* -------------- sourcefile search button ---------------- */
  554.           when rxSubID = 3 then
  555.           do
  556.                         /* search the sourcefile                      */
  557.             thisFileMask = sourceFiles.__CurPath || '\*.CMD'
  558.             rxFile 'LOAD' 'THISFILEMASK' 'OK | Select the source file'
  559.  
  560.             if ( rc = '' ) & thisFileMask <> '' then
  561.             do
  562.               sourceFiles.__CurPath = filespec( 'D', thisFileMask ) || ,
  563.                                       fileSpec( 'P', thisFileMask )
  564.               if length( sourceFiles.__CurPath ) > 3 & ,
  565.                  right( sourceFiles.__CurPath,1 ) = '\' then
  566.                 sourceFiles.__CurPath = dbrright( sourceFiles.__CurPath,1 )
  567.  
  568. /*
  569.                         /* add the new entry to the drop down list    */
  570.               RxSet '"'MainWindowTitle'"' md.__SourceFileDropBox 1 'ADD' thisFileMask || '| -1'
  571. */
  572.                         /* update the entry field of the drop box    */
  573.               RxSet '"'MainWindowTitle'"' md.__SourceFileDropBox 1 'VAL' thisFileMask
  574.  
  575.             end /* if rc = '' & ... */
  576.  
  577.           end /* when */
  578.  
  579.           /* -------------- target file search push button ---------- */
  580.           when rxSubID = 2 then
  581.           do
  582.                         /* search the targetfile                      */
  583.             thisFileMask = targetFiles.__CurPath || '\*.CMD'
  584.             rxFile 'LOAD' 'THISFILEMASK' 'OK | Select the target file'
  585.  
  586.             if ( rc = '' ) & thisFileMask <> '' then
  587.             do
  588.               targetFiles.__CurPath = filespec( 'D', thisFileMask ) || ,
  589.                                       fileSpec( 'P', thisFileMask )
  590.               if length( targetFiles.__CurPath ) > 3 & ,
  591.                  right( targetFiles.__CurPath,1 ) = '\' then
  592.                 targetFiles.__CurPath = dbrright( targetFiles.__CurPath,1 )
  593.  
  594. /*
  595.                         /* add the new entry to the drop down list    */
  596.               RxSet '"'MainWindowTitle'"' md.__TargetFileDropBox 1 'ADD' thisFileMask || '| -1'
  597. */
  598.                         /* update the entry field of the drop box    */
  599.               RxSet '"'MainWindowTitle'"' md.__TargetFileDropBox 1 'VAL' thisFileMask
  600.  
  601.             end /* if rc = '' & ... */
  602.  
  603.           end /* when */
  604.  
  605.           /* -------------- copyright file search push button ------- */
  606.           when rxSubID = 1 then
  607.           do
  608.                         /* search the copyrightfile                   */
  609.  
  610.             thisFileMask = CopyrightFiles.__CurPath || '\*.CMD'
  611.             rxFile 'LOAD' 'THISFILEMASK' 'OK | Select the copyright file'
  612.  
  613.             if ( rc = '' ) & thisFileMask <> '' then
  614.             do
  615.               CopyrightFiles.__CurPath = filespec( 'D', thisFileMask ) || ,
  616.                                       fileSpec( 'P', thisFileMask )
  617.               if length( CopyrightFiles.__CurPath ) > 3 & ,
  618.                  right( CopyrightFiles.__CurPath,1 ) = '\' then
  619.                 CopyrightFiles.__CurPath = dbrright( CopyrightFiles.__CurPath,1 )
  620.  
  621. /*
  622.                         /* add the new entry to the drop down list    */
  623.               RxSet '"'MainWindowTitle'"' md.__CopyrightFileDropBox 1 'ADD' thisFileMask || '| -1'
  624. */
  625.                         /* update the entry field of the drop box    */
  626.               RxSet '"'MainWindowTitle'"' md.__CopyrightFileDropBox 1 'VAL' thisFileMask
  627.  
  628.             end /* if rc = '' & ... */
  629.  
  630.           end /* when */
  631.  
  632.           /* -------------- unknown push button --------------------- */
  633.           otherwise
  634.             nop
  635.  
  636.         end /* select */
  637.  
  638.       end /* when */
  639.  
  640.  
  641.       /* ------------------ create tokenimage / edit / use def.       */
  642.       /*                    target dir push buttons ----------------- */
  643.       when rxID = md.__MiscActionPushButtons then
  644.       do
  645.  
  646.         select
  647.  
  648.           /* -------------- create Tokenimage push button ----------- */
  649.           when rxSubID = 3 then
  650.           do
  651.                         /* Note: We use a select block here to avoid  */
  652.                         /*       using a lot of nested IF statements  */
  653.  
  654.             select
  655.  
  656.               when sourceFiles.0 = '' then
  657.                 call ShowErrorMsg , 'No sourceFile selected'
  658.  
  659.               when FileExist( sourceFiles.0 ) <= 0 then
  660.                 call ShowErrorMsg , 'The file '  || crlf ,
  661.                                     sourceFiles.0      || crlf ,
  662.                                     'does not exist'
  663.  
  664.               when translate( FileSpec( 'E', sourceFiles.0 ) ) <> 'CMD' then
  665.                 call ShowErrorMsg , 'The extension of the sourceFile must be .CMD'
  666.  
  667.               otherwise
  668.               do
  669.                 testLine = lineIn( sourceFiles.0 )
  670.                 call stream sourceFiles.0, 'c', 'CLOSE'
  671.  
  672.                 if left( testLine,2 ) <> '/' || '*' then
  673.                    call ShowErrorMsg , 'The file '         crlf || ,
  674.                                         sourceFiles.0      crlf || ,
  675.                                        'is not a valid REXX program'
  676.                 else
  677.                 do
  678.                         /* clear the PM message queue                 */
  679.                   RxDlg '""' 255
  680.  
  681.                                                 /* show a status msg                  */
  682.                   call ShowStatusMsg 'OPEN', 'Creating the tokenimage of ',
  683.                                              '00'x sourceFiles.0
  684.  
  685.                         /* clear the PM message queue                 */
  686.                   RxDlg '""' 255
  687.  
  688.                                 /* create the token image             */
  689.                   ADDRESS 'CMD' sourceFiles.0 ' //t 2>NUL 1>NUL'
  690.  
  691.                         /* clear the PM message queue                 */
  692.                   RxDlg '""' 255
  693.  
  694.                                 /* close the status msg               */
  695.                   call ShowStatusMsg 'CLOSE'
  696.  
  697.                         /* clear the PM message queue                 */
  698.                   RxDlg '""' 255
  699.  
  700.                             /* check if the creation was successfull  */
  701.                   testRC = SysGetEA( sourceFiles.0, 'REXX.TOKENSIMAGE', 'testEA' )
  702.                   if testRC <> 0 | length( testEA ) = 0 then
  703.                     call ShowErrorMsg , 'Error creating the tokenimage of the file' || crlf || ,
  704.                                         sourceFiles.0                               || crlf || ,
  705.                                         'Hint: Either the file is read-only or the program is to big'
  706.                   else
  707.                     call ShowMsg 'Tokenimage of the file' crlf || ,
  708.                                  sourceFiles.0            crlf || ,
  709.                                  'succesfully created.'
  710.                 end /* else */
  711.               end /* otherwise */
  712.             end /* select */
  713.           end /* when */
  714.  
  715.           /* -------------- use default target dir push button ------ */
  716.           when rxSubID = 2 then
  717.           do
  718.             if REXXCC2.__DefaultTargetDir <> '' then
  719.               RxSet '"'mainWindowTitle'"' md.__TargetFileDropBox 1 'VAL' REXXCC2.__DefaultTargetDir
  720.             else
  721.               call ShowErrorMsg , 'No default targetDir selected.' || crlf || ,
  722.                                   'Hint: Use the options dialog to select a default targetDir'
  723.  
  724.           end /* when */
  725.  
  726.           /* -------------- edit copyrightfile push button ---------- */
  727.           when rxSubID = 1 then
  728.           do
  729.             ADDRESS 'CMD' REXXCC2.__EditorName  copyrightFiles.0
  730.           end /* when */
  731.  
  732.           /* -------------- unknown push button --------------------- */
  733.           otherwise
  734.             nop
  735.  
  736.         end /* select */
  737.  
  738.       end /* when */
  739.  
  740.  
  741.       /* ------------------ mode radio buttons ---------------------- */
  742.       when rxID = md.__ModeRadioButtons  then
  743.       do
  744.                         /* radio buttons                              */
  745.  
  746.                         /* RXSBUID : no. of active radio button       */
  747.                         /*  2: compile 1: compress                    */
  748.       end /* when */
  749.  
  750.       /* ------------------ REXXCC option checkboxes ---------------- */
  751.       when rxID = md.__OptionCheckBoxes then
  752.       do
  753.                         /* check boxes                                */
  754.  
  755.                         /* RXSBUID : no. of the checked box           */
  756.       end /* when */
  757.  
  758.       /* ------------------ action push buttons --------------------- */
  759.       when rxID = md.__ActionPushButtons then
  760.       do
  761.                         /* result push buttons                        */
  762.  
  763.                         /* RXSBUID contains the no. of the button     */
  764.                         /*  1:exit 2:reset 3:options 4:compile        */
  765.         select
  766.  
  767.           /* -------------- exit button ----------------------------- */
  768.           when rxSubID = 1 then
  769.           do
  770.                         /* update the REXX variables with the dialog  */
  771.                         /* values                                     */
  772.             call UpdateGlobalREXXVariables
  773.  
  774.                                 /* close the main dialog              */
  775.             RxDlg '"'mainWindowTitle'"' 4
  776.  
  777.                         /* clear the PM message queue                 */
  778.             RxDlg '""' 255
  779.  
  780.             if wordPos( '1', REXXCC2.__Options ) <> 0 then
  781.             do
  782.                         /* save the current configuration             */
  783.               call LoadSaveConfigData 'SAVE' , REXXCC2.__IniFileName
  784.             end /* if wordPos( ... */
  785.  
  786.                         /* clear the PM message queue                 */
  787.             RxDlg '""' 255
  788.  
  789.                         /* set the program return code                */
  790.             prog.__ExitCode = 0
  791.             leave
  792.           end /* when */
  793.  
  794.           /* -------------- reset button ---------------------------- */
  795.           when rxSubID = 2 then
  796.           do
  797.                         /* clear the lists of the drop down boxes     */
  798.             call ClearFileLists
  799.           end /* when */
  800.  
  801.           /* -------------- options button -------------------------- */
  802.           when rxSubID = 3 then
  803.           do
  804.                         /* update the REXX variables with the dialog  */
  805.                         /* values                                     */
  806.             call UpdateGlobalREXXVariables
  807.  
  808.                                 /* close the main dialog              */
  809.                                 /* to force an update if new options  */
  810.                                 /* are loaded                         */
  811.             RxDlg '"'mainWindowTitle'"' 4
  812.  
  813. /*
  814.                         /* (*?*) hide the drop down boxes -           */
  815.                         /* neccessary if we don't close the main dlg  */
  816.                         /* because of a bug (?) in Rexx Dialog 1.0    */
  817.             RxSet '"'MainWindowTitle'"' md.__SourceFileDropBox     1 'HIDE' 1
  818.             RxSet '"'MainWindowTitle'"' md.__TargetFileDropbox     1 'HIDE' 1
  819.             RxSet '"'MainWindowTitle'"' md.__CopyrightFileDropBox  1 'HIDE' 1
  820. */
  821.  
  822.                         /* call the option dialog                     */
  823.             call OptionDialog
  824.  
  825. /*
  826.                         /* (*?*) show the drop down boxes again       */
  827.             RxSet '"'MainWindowTitle'"' md.__SourceFileDropBox     1 'SHOW' 1
  828.             RxSet '"'MainWindowTitle'"' md.__TargetFileDropbox     1 'SHOW' 1
  829.             RxSet '"'MainWindowTitle'"' md.__CopyrightFileDropBox  1 'SHOW' 1
  830. */
  831.           end /* when */
  832.  
  833.  
  834.           /* -------------- unknown button -------------------------- */
  835.           otherwise
  836.           do
  837.           end /* otherwise */
  838.  
  839.         end /* select */
  840.  
  841.       end /* when */
  842.  
  843.       /* ------------------ Compile/Compress Push button              */
  844.       when rxID = md.__CompilePushButton | rxID = md.__CompressPushButton then
  845.       do
  846.  
  847.                     /* update the REXX variables with the dialog      */
  848.                     /* values                                         */
  849.         call UpdateGlobalREXXVariables
  850.  
  851.         startCompile = 0
  852.  
  853.         if REXXCC2.__CompilerName = '' then
  854.         do
  855.           call ShowErrorMsg , 'No compiler selected.' || crlf || ,
  856.                               'Hint: Use the options dialog to select a compiler'
  857.         end /* if REXXCC2.__CompilerName = '' then */
  858.         else
  859.         do
  860.           if stream( REXXCC2.__CompilerName, 'c', 'QUERY EXIST' ) = '' then
  861.             call ShowErrorMsg , 'Can not find the compiler ' || crLF || ,
  862.                               REXXCC2.__CompilerName || '!' || crLF || ,
  863.                               'Hint: Use the options dialog to select a compiler'
  864.           else
  865.             startCompile = 1
  866.         end /* else */
  867.  
  868.         if startCompile = 1 & ,
  869.            CheckCompiler( REXXCC2.__CompilerName ) <> 1 then
  870.         do
  871.           if ShowWarningMsg( 4, REXXCC2.__CompilerName ,
  872.                                 ' seems not to be a valid compiler!' || crlf || ,
  873.                                 'Press YES to use it anyway' ) <> 6 then
  874.             startCompile = 0
  875.         end /* if CheckCompiler( ... */
  876.  
  877.         select
  878.  
  879.           when startCompile <> 1 then
  880.             nop
  881.  
  882.           when sourceFiles.0 = '' & wordPos( '3', REXXCC2.__Options ) = 0 then
  883.             call ShowErrorMsg , 'No sourcefile entered'
  884.  
  885.           when targetFiles.0 = '' & wordPos( '3', REXXCC2.__Options ) = 0 then
  886.             call ShowErrorMsg , 'No targetfile entered'
  887.  
  888.           otherwise
  889.           do
  890.  
  891.                             /* close the main dialog                  */
  892.             RxDlg '"'mainWindowTitle'"' 4
  893.  
  894.                             /* start the compiler                     */
  895.             call StartCompile
  896.           end /* otherwise */
  897.  
  898.         end /* select */
  899.  
  900.       end /* when */
  901.  
  902.       /* ------------------ Linecount spin -------------------------- */
  903.       when rxID = md.__LineCountSpin then
  904.       do
  905.                         /* spin entry for LineCount                   */
  906.       end /* when */
  907.  
  908.       /* ------------------ about push button ----------------------- */
  909.       when rxID = md.__AboutPushButtons then
  910.       do
  911.  
  912.                         /* about push button                          */
  913.  
  914.                                 /* close the main dialog              */
  915.                                 /* to force an update                 */
  916.         RxDlg '"'mainWindowTitle'"' 4
  917.  
  918.         rxSay prog.__vName prog.__Version ' - PM frontend for REXXCC'            crlf || ,
  919.               prog.__vCopyright                                                  crlf || ,
  920.               'See the source code for the limitations of this version.'         crlf || ,
  921.               'See the REXXCC documentation for further information.'            crlf || ,
  922.               ''                                                                 crlf || ,
  923.               'REXXCC/2 uses the famous "Rexx Dialog" package from Jeff Glatt.' || ,
  924.               ' See the file RX.INF for further information about "Rexx Dialog".' ,
  925.               '|' 0+48 'About'
  926.  
  927.       end /* when */
  928.  
  929.       /* ------------------ unknow result --------------------------- */
  930.       otherwise
  931.       do
  932.       end /* otherwise */
  933.  
  934.     end /* select */
  935.  
  936.   end /* do forever */
  937.  
  938. exit prog.__ExitCode
  939.  
  940. /* ------------------------------------------------------------------ */
  941. /* UpdateGlobalREXXVariables                                          */
  942. /*                                                                    */
  943. /* Function: Update the global REXX variables with the dialog values  */
  944. /*                                                                    */
  945. /* Usage:    UpdateGlobalREXXVariables                                */
  946. /*                                                                    */
  947. /* where:    -                                                        */
  948. /*                                                                    */
  949. /* returns:  nothing                                                  */
  950. /*                                                                    */
  951. UpdateGlobalREXXVariables:
  952.                         /* update the global variables                */
  953.  
  954.                     /* check if the filename is already in the list   */
  955.   AddFileName = ( sourceFiles.0 <> '' )
  956.  
  957.   do i = 1 while sourceFiles.i <> '' & AddFileName = 1
  958.     if translate( sourceFiles.i ) = translate( sourceFiles.0 ) then
  959.       AddFileName = 0
  960.   end /* do */
  961.  
  962.   if AddFileName = 1 then
  963.   do
  964.                         /* filename not yet in the list -- add it     */
  965.     sourceFiles.i = sourceFiles.0
  966.  
  967. /*
  968.                         /* add the source file to the drop down list  */
  969.     RxSet '"'MainWindowTitle'"' md.__SourceFileDropBox 1 'ADD' sourceFiles.0 || '| -1'
  970. */
  971.  
  972.   end /* if AddFileName = 1 then */
  973.  
  974.                     /* check if the filename is already in the list   */
  975.   AddFileName = ( targetFiles.0 <> '' )
  976.   do i = 1 while targetFiles.i <> '' & AddFileName = 1
  977.     if translate( TargetFiles.i ) = translate( TargetFiles.0 ) then
  978.       AddFileName = 0
  979.   end /* do */
  980.   if AddFileName = 1 then
  981.   do
  982.                         /* filename not yet in the list -- add it     */
  983.     targetFiles.i = targetFiles.0
  984.  
  985. /*
  986.                         /* add the new entry to the drop down list    */
  987.     RxSet '"'MainWindowTitle'"' md.__TargetFileDropBox 1 'ADD' targetFiles.0 || '| -1'
  988. */
  989.  
  990.   end /* if AddFileName = 1 then */
  991.  
  992.                     /* check if the filename is already in the list   */
  993.   AddFileName = ( copyrightFiles.0 <> '' )
  994.   do i = 1 while  CopyrightFiles.i <> '' & AddFileName = 1
  995.     if translate( CopyrightFiles.i ) = translate( CopyrightFiles.0 ) then
  996.       AddFileName = 0
  997.   end /* do */
  998.   if AddFileName = 1 then
  999.   do
  1000.                         /* filename not yet in the list -- add it     */
  1001.     copyrightFiles.i = copyrightFiles.0
  1002.  
  1003. /*
  1004.                         /* add the new entry to the drop down list    */
  1005.     RxSet '"'MainWindowTitle'"' md.__TargetFileDropBox 1 'ADD' CopyrightFiles.0 || '| -1'
  1006. */
  1007.  
  1008.   end /* if AddFileName = 1 then */
  1009.  
  1010.   REXXCC.__Mode      = value( 'RXVAL.' || md.__ModeRadioButtons )
  1011.   REXXCC.__Options   = value( 'RXVAL.' || md.__OptionCheckBoxes )
  1012.   REXXCC.__LineCount = value( 'RXVAL.' || md.__LineCountSpin )
  1013.  
  1014. RETURN
  1015.  
  1016. /* ------------------------------------------------------------------ */
  1017. /* OptionDialog                                                       */
  1018. /*                                                                    */
  1019. /* Function: Show & handle the option dialog                          */
  1020. /*                                                                    */
  1021. /* Usage:    OptionDialog                                             */
  1022. /*                                                                    */
  1023. /* where:    -                                                        */
  1024. /*                                                                    */
  1025. /* returns:  nothing                                                  */
  1026. /*                                                                    */
  1027. OptionDialog: PROCEDURE expose (exposeList)
  1028.  
  1029. InitOptionDialogAgain:
  1030.  
  1031.                     /* copy the global values into local variables    */
  1032.   curIniFile          = REXXCC2.__IniFileName
  1033.   curCompiler         = REXXCC2.__CompilerName
  1034.   curREXXCC2Options   = REXXCC2.__Options
  1035.   curEditor           = REXXCC2.__EditorName
  1036.   curDefaultTargetDir = REXXCC2.__DefaultTargetDir
  1037.  
  1038.                     /* init the variables for the dialog              */
  1039.  
  1040.                     /* title of the dialog                            */
  1041.   OptionWindowTitle = prog.__vName prog.__Version || ' - Options'
  1042.  
  1043.   i = 0
  1044.  
  1045.   i = i+1;                      ; op.__IniFileText = i
  1046.   RXTYPE.i  = 'TEXT'
  1047.   RXFLAGS.i = ' '
  1048.   RXLABEL.i = 'Current inifile:'
  1049.   RXINFO.i  = '1 1 400'
  1050.   RXVAL.i   = ' '
  1051.   RXX.i     = 10
  1052.   RXY.i     = 315
  1053.  
  1054.   i = i+1;                      ; op.__CurIniFileName = i
  1055.   RXTYPE.i  = 'TEXT'
  1056.   RXFLAGS.i = ' '
  1057.   if curIniFile = '' then
  1058.     RXLABEL.i = '*** no inifile selected ***'
  1059.   else
  1060.     RXLABEL.i = PackFileName( curIniFile, 50 )
  1061.   RXINFO.i  = '1 1 400'
  1062.   RXVAL.i   = ' '
  1063.   RXX.i     = 10
  1064.   RXY.i     = 295
  1065.  
  1066.   i=i+1                         ; op.__ChangeIniFilePushButton = i
  1067.   RXTYPE.i  = 'PUSH'
  1068.   RXFLAGS.i = 'END'
  1069.   RXLABEL.i = 'Change Inifile'
  1070.   RXINFO.i  = '1 1 225'
  1071.   RXVAL.i   = ' '
  1072.   RXX.i     = 380
  1073.   RXY.i     = 315
  1074.  
  1075.   i = i+1;                      ; op.__CompilerText = i
  1076.   RXTYPE.i = 'TEXT'
  1077.   RXFLAGS.i = ' '
  1078.   RXLABEL.i = 'Current compiler:'
  1079.   RXINFO.i  = '1 1'
  1080.   RXVAL.i   = ' '
  1081.   RXX.i     = 10
  1082.   RXY.i     = 265
  1083.  
  1084.   i = i+1;                      ; op.__CurCompilerName = i
  1085.   RXTYPE.i = 'TEXT'
  1086.   RXFLAGS.i = ' '
  1087.   if curCompiler = '' then
  1088.     RXLABEL.i = '*** no compiler selected ***'
  1089.   else
  1090.     RXLABEL.i = PackFileName( curCompiler, 50 )
  1091.   RXINFO.i  = '1 1'
  1092.   RXVAL.i   = ' '
  1093.   RXX.i     = 10
  1094.   RXY.i     = 245
  1095.  
  1096.   i=i+1;                        ; op.__CompilerSearchPushButton = i
  1097.   RXTYPE.i  = 'PUSH'
  1098.   RXFLAGS.i = 'END'
  1099.   RXLABEL.i = 'Change Compiler'
  1100.   RXINFO.i  = '1 1 225'
  1101.   RXVAL.i   = ' '
  1102.   RXX.i     = 380
  1103.   RXY.i     = 265
  1104.  
  1105.   i = i+1;                      ; op.__EditorText = i
  1106.   RXTYPE.i = 'TEXT'
  1107.   RXFLAGS.i = ' '
  1108.   RXLABEL.i = 'Current editor:'
  1109.   RXINFO.i  = '1 1'
  1110.   RXVAL.i   = ' '
  1111.   RXX.i     = 10
  1112.   RXY.i     = 215
  1113.  
  1114.   i = i+1;                      ; op.__CurEditorName = i
  1115.   RXTYPE.i = 'TEXT'
  1116.   RXFLAGS.i = ' '
  1117.   if curEditor = '' then
  1118.     RXLABEL.i = '*** no editor selected ***'
  1119.   else
  1120.     RXLABEL.i = PackFileName( curEditor, 50 )
  1121.   RXINFO.i  = '1 1'
  1122.   RXVAL.i   = ' '
  1123.   RXX.i     = 10
  1124.   RXY.i     = 195
  1125.  
  1126.   i=i+1;                        ; op.__EditorSearchPushButton = i
  1127.   RXTYPE.i  = 'PUSH'
  1128.   RXFLAGS.i = 'END'
  1129.   RXLABEL.i = 'Change Editor'
  1130.   RXINFO.i  = '1 1 225'
  1131.   RXVAL.i   = ' '
  1132.   RXX.i     = 380
  1133.   RXY.i     = 215
  1134.  
  1135.   i = i+1;                      ; op.__TargetDirText = i
  1136.   RXTYPE.i = 'TEXT'
  1137.   RXFLAGS.i = ' '
  1138.   RXLABEL.i = 'Current default TargetDir:'
  1139.   RXINFO.i  = '1 1'
  1140.   RXVAL.i   = ' '
  1141.   RXX.i     = 10
  1142.   RXY.i     = 170
  1143.  
  1144.   i = i+1;                      ; op.__CurTargetDirName = i
  1145.   RXTYPE.i = 'TEXT'
  1146.   RXFLAGS.i = ' '
  1147.   if curDefaultTargetDir = '' then
  1148.     RXLABEL.i = '*** no default target directory selected ***'
  1149.   else
  1150.     RXLABEL.i = PackFileName( curDefaultTargetDir, 50 )
  1151.   RXINFO.i  = '1 1'
  1152.   RXVAL.i   = ' '
  1153.   RXX.i     = 10
  1154.   RXY.i     = 150
  1155.  
  1156.   i=i+1;                        ; op.__TargetDirSearchPushButton = i
  1157.   RXTYPE.i  = 'PUSH'
  1158.   RXFLAGS.i = 'END'
  1159.   RXLABEL.i = 'Change default TargetDir'
  1160.   RXINFO.i  = '1 1 225'
  1161.   RXVAL.i   = ' '
  1162.   RXX.i     = 380
  1163.   RXY.i     = 170
  1164.  
  1165.   i=i+1                         ; op.__REXXCC2CheckBox = i
  1166.   RXTYPE.i  = 'CHECK'
  1167.   RXFLAGS.i = ' '
  1168.   RXLABEL.i = 'Save options at program end | ' ,
  1169.               'Use Environment variable REXXCC |' ,
  1170.               'Edit compile command before executing | ' ,
  1171.               'REXXCC/2 Options '
  1172.   RXINFO.i  = '3 1 0'
  1173.   RXVAL.i   = curREXXCC2Options
  1174.   RXX.i     = 15
  1175.   RXY.i     = 40
  1176.  
  1177.   i=i+1;                        ; op.__SaveConfigDataPushButton = i
  1178.   RXTYPE.i  = 'PUSH'
  1179.   RXFLAGS.i = 'END'
  1180.   RXLABEL.i = 'Save configuration'
  1181.   RXINFO.i  = '2 1 175'
  1182.   RXVAL.i   = ' '
  1183.   RXX.i     = 430
  1184.   RXY.i     = 35
  1185.  
  1186.  
  1187.   i=i+1;                        ; op.__LoadConfigDataPushButton = i
  1188.   RXTYPE.i  = 'PUSH'
  1189.   RXFLAGS.i = 'END'
  1190.   RXLABEL.i = 'Load configuration'
  1191.   RXINFO.i  = '2 1 175'
  1192.   RXVAL.i   = ' '
  1193.   RXX.i     = 430
  1194.   RXY.i     = 60
  1195.  
  1196.   i=i+1;                        ; op.__ResultPushButtons = i
  1197.   RXTYPE.i  = 'RESULT'
  1198.   RXFLAGS.i = 'BOOL'
  1199.   RXLABEL.i = ' '
  1200.   RXINFO.i  = '1 2'
  1201.   RXVAL.i   = ' '
  1202.   RXX.i     = 250
  1203.   RXY.i     = 5
  1204.  
  1205.                                 /* number of groups in this dialog    */
  1206.   noOfGroupsInOptionWIn = i
  1207.  
  1208.                                 /* show the dialog                    */
  1209.   RxDlg noOfGroupsInOptionWin   ,
  1210.         '"'optionWindowTitle'"' ,
  1211.         'WINDOW.__OPTIONWINDOWDIM'  ,
  1212.         'NOCLOSE|MODAL|KEYS|RESULT'
  1213.  
  1214.  
  1215.                         /* change the size of the text fields         */
  1216.                         /* (*?*) this is neccessary because the       */
  1217.                         /* initial size of the fields is limited to   */
  1218.                         /* 31                                         */
  1219.   RxSet '"'optionWindowTitle'"' op.__CurIniFileName   1 'SIZE' 475
  1220.   RxSet '"'optionWindowTitle'"' op.__CurCompilerName  1 'SIZE' 475
  1221.   RxSet '"'optionWindowTitle'"' op.__CurEditorName    1 'SIZE' 475
  1222.   RxSet '"'optionWindowTitle'"' op.__CurTargetDirName 1 'SIZE' 475
  1223.  
  1224.   do forever
  1225.                         /* perform user actions                       */
  1226.     RxDlg '"'optionWindowTitle'"' 0
  1227.  
  1228.                         /* update the REXX variables with the user    */
  1229.                         /* input                                      */
  1230.     RxDlg '"'optionWindowTitle'"' 2
  1231.  
  1232.                         /* clear the PM message queue                 */
  1233.     RxDlg '""' 255
  1234.  
  1235.     /* ------------------ alt keycode processing -------------------- */
  1236.     select
  1237.  
  1238.       when rxID = -1 then
  1239.       do
  1240.                         /* (*?*) simulate accelerator keys -- see     */
  1241.                         /*       note for the main dialog             */
  1242.         rxSubId = translate( rxSubID )
  1243.  
  1244.         possibleKeys    = 'I C L S E T'
  1245.         rxIDsForKeys    = op.__ChangeIniFilePushButton ,
  1246.                           op.__CompilerSearchPushbutton ,
  1247.                           op.__LoadConfigDataPushButton ,
  1248.                           op.__SaveConfigDataPushButton ,
  1249.                           op.__ChangeEditorPushButton ,
  1250.                           op.__TargetDirSearchbutton
  1251.  
  1252.         rxSubIDsForKeys = '1 1 1 1 1 1'
  1253.  
  1254.         i = wordPos( rxSubId, possibleKeys )
  1255.         if i <> 0 then
  1256.         do
  1257.           rxID = word( rxIDsForKeys, i )
  1258.           rxSubID = word( rxSubIDsForKeys, i )
  1259.         end /* if i <> 0 then */
  1260.       end /* if */
  1261.  
  1262.       otherwise
  1263.         nop
  1264.     end /* select */
  1265.  
  1266.     select
  1267.  
  1268.       /* ------------------ Close & abort --------------------------- */
  1269.       when rxID <= 0 then
  1270.       do
  1271.                                 /* end the dialog                     */
  1272.         leave
  1273.       end /* when */
  1274.  
  1275.       /* ------------------ ChangeIniFile push button --------------- */
  1276.  
  1277.       when rxID = op.__ChangeIniFilePushButton then
  1278.       do
  1279.                         /* get a new path for the ini file            */
  1280.         tempStr = GetIniFilePathDialog()
  1281.         if tempStr <> '' then
  1282.         do
  1283.           tempStr = tempStr || prog.__IniFileName
  1284.  
  1285.           if DriveReady( tempStr ) <> 1 then
  1286.             call ShowErrorMsg , 'The drive ' || ,
  1287.                              substr( tempStr,1,2 ) || ,
  1288.                              ' is not ready'
  1289.           else if WriteReadTestIniFile( 'TEST', tempStr ) >= 0 then
  1290.           do
  1291.                                 /* choosen inifile is okay            */
  1292.  
  1293.                                 /* change the value in the dialog     */
  1294.             curIniFile = tempStr
  1295.             RxSet '"'optionWindowTitle'"',
  1296.                   op.__CurIniFileName 1 'VAL' PackFileName( tempStr, 50 )
  1297.           end /* if WriteReadTestIniFile( ... */
  1298.           else
  1299.             call ShowErrorMsg , 'The format of the ini file ' || crlf || ,
  1300.                                  tempStr                      || crlf || ,
  1301.                                 'is invalid'
  1302.         end /* if tempStr1 <> '' then */
  1303.  
  1304.       end /* when */
  1305.  
  1306.       /* ------------------ CompilerSearch push button -------------- */
  1307.       when rxID = op.__CompilerSearchPushButton then
  1308.       do forever
  1309.                         /* search the compiler                        */
  1310.         tempStr = curCompiler
  1311.         rxFile 'LOAD' 'TEMPSTR' 'OK | Select the compiler'
  1312.  
  1313.         if ( rc = '' ) & tempStr <> '' then
  1314.         do
  1315.           if CheckCompiler( tempStr ) = 1 then
  1316.           do
  1317.             curCompiler = tempStr
  1318.                                 /* change the value in the dialog     */
  1319.             RxSet '"'optionWindowTitle'"',
  1320.                   op.__CurCompilerName 1 'VAL' PackFileName( tempStr, 50 )
  1321.             leave
  1322.           end /* if CheckCompiler( tempStr ) <> '' then */
  1323.           else
  1324.             call ShowErrorMsg , tempStr || ' is not a valid compiler'
  1325.         end /* if */
  1326.         else
  1327.           leave
  1328.       end /* when */
  1329.  
  1330.       /* ------------------ EditorSearch push button ---------------- */
  1331.       when rxID = op.__EditorSearchPushButton then
  1332.       do
  1333.         if ShowWarningMsg( 4, 'The current editor is '    || crlf || ,
  1334.                            PackFileName( curEditor, 40 )  || crlf || ,
  1335.                            'Do you want to change it?'    || crlf || ,
  1336.                            'Caution: You can only use a PM editor' ,
  1337.                       ) = 6 then
  1338.         do forever
  1339.                         /* search the editor                          */
  1340.           tempStr = curEditor
  1341.           rxFile 'LOAD' 'TEMPSTR' 'OK | Select the editor'
  1342.  
  1343.           if ( rc = '' ) & tempStr <> '' then
  1344.           do
  1345.             if stream( tempStr, 'c', 'QUERY EXIST' ) <> '' then
  1346.             do
  1347.               curEditor = tempStr
  1348.                                 /* change the value in the dialog     */
  1349.               RxSet '"'optionWindowTitle'"',
  1350.                     op.__CurEditorName 1 'VAL' PackFileName( tempStr, 50 )
  1351.               leave
  1352.             end /* if stream( ... */
  1353.             else
  1354.               call ShowErrorMsg ,'Program "' || tempStr || '" not found'
  1355.           end /* if */
  1356.           else
  1357.             leave
  1358.  
  1359.         end /* do forever */
  1360.       end /* when */
  1361.  
  1362.       /* ------------------ Change default targetdir push button ---- */
  1363.       when rxID = op.__TargetDirSearchPushButton then
  1364.       do
  1365.                         /* get the default target directory           */
  1366.         tempStr = curDefaultTargetDir || 'dummy'
  1367.         rxFile 'LOAD' 'TEMPSTR' 'OK | Select a file in the default target directory'
  1368.  
  1369.         if ( rc = '' ) & tempStr <> '' then
  1370.         do
  1371.           curDefaultTargetDir = fileSpec( 'D', tempStr ) || ,
  1372.                                 fileSpec( 'P', tempStr )
  1373.  
  1374.                                 /* change the value in the dialog     */
  1375.           RxSet '"'optionWindowTitle'"',
  1376.                 op.__CurTargetDirName 1 'VAL' PackFileName( curDefaultTargetDir, 50 )
  1377.         end /* if ( rc = '' ) & ... */
  1378.       end /* when */
  1379.  
  1380.       /* ------------------ LoadConfigData push button -------------- */
  1381.       when rxID = op.__LoadConfigDataPushButton then
  1382.       do
  1383.                         /* load configuration push button             */
  1384.         if curIniFile = '' then
  1385.         do
  1386.                         /* no inifile selcected                       */
  1387.           tempStr = GetIniFilePathDialog()
  1388.           if tempStr <> '' then
  1389.             tempStr = tempStr || prog.__IniFileName
  1390.         end
  1391.         else
  1392.           tempStr = curIniFile
  1393.  
  1394.         if tempStr <> '' then
  1395.         do
  1396.           if LoadSaveConfigData( 'LOAD', tempStr ) = 1 then
  1397.           do
  1398.                         /* ini file successfully loaded               */
  1399.                         /* Note: LoadSaveConfigData changes the       */
  1400.                         /*       global variable!                     */
  1401.             curIniFile = REXXCC2.__IniFileName
  1402.  
  1403.                         /* close the dialog                           */
  1404.             RxDlg '"'optionWindowTitle'"' 4
  1405.  
  1406.             call ShowMsg , 'Configuration data loaded.'
  1407.  
  1408.                         /* init stem for the dialog variables again   */
  1409.                         /* and create the the dialog again            */
  1410.                         /* no good style -- but works                 */
  1411.             signal InitOptionDialogAgain
  1412.  
  1413.           end /* if LoadSaveConfigData( ... */
  1414.         end /* if tempStr <> '' then */
  1415.       end /* when */
  1416.  
  1417.       /* ------------------ SaveConfigData push button -------------- */
  1418.       when rxID = op.__SaveConfigDataPushButton then
  1419.       do
  1420.                         /* save configuration push button             */
  1421.         if curIniFile = '' then
  1422.         do
  1423.                         /* no inifile selcected                       */
  1424.           tempStr = GetIniFilePathDialog()
  1425.           if tempStr <> '' then
  1426.             tempStr = tempStr || prog.__IniFileName
  1427.         end
  1428.         else
  1429.           tempStr = curIniFile
  1430.  
  1431.         if tempStr <> '' then
  1432.         do
  1433.                     /* save the new values in the global variables    */
  1434.           REXXCC2.__CompilerName     = curCompiler
  1435.           REXXCC2.__IniFileName      = curIniFile
  1436.           REXXCC2.__EditorName       = curEditor
  1437.           REXXCC2.__DefaultTargetDir = curDefaultTargetDir
  1438.           REXXCC2.__Options = value( 'RXVAL.' || op.__REXXCC2CheckBox )
  1439.  
  1440.           if LoadSaveConfigData( 'SAVE', tempStr ) = 1 then
  1441.           do
  1442.             call ShowMsg , 'Configuration data saved.'
  1443.                         /* Note: LoadSaveConfigData changes the       */
  1444.                         /*       global variable!                     */
  1445.             curIniFile = REXXCC2.__IniFileName
  1446.  
  1447.                                 /* change the value in the dialog     */
  1448.             RxSet '"'optionWindowTitle'"',
  1449.                   op.__CurIniFileName 1 'VAL' PackFileName( curIniFile, 50 )
  1450.           end /* if */
  1451.         end /* if tempStr <> '' then */
  1452.       end /* when */
  1453.  
  1454.       /* ------------------ Result push buttons --------------------- */
  1455.       when rxID = op.__ResultPushButtons then
  1456.       do
  1457.                         /* Result push buttons                        */
  1458.         i = op.__ResultPushButtons
  1459.  
  1460.         /* ---------------- OK push button -------------------------- */
  1461.         if RXVAL.i = 1 then
  1462.         do
  1463.                     /* save the new values in the global variables    */
  1464.           REXXCC2.__CompilerName     = curCompiler
  1465.           REXXCC2.__IniFileName      = curIniFile
  1466.           REXXCC2.__EditorName       = curEditor
  1467.           REXXCC2.__DefaultTargetDir = curDefaultTargetDir
  1468.           REXXCC2.__Options = value( 'RXVAL.' || op.__REXXCC2CheckBox )
  1469.         end /* if */
  1470.  
  1471.         leave
  1472.       end /* when */
  1473.  
  1474.       /* ------------------ unknown result code --------------------- */
  1475.       otherwise
  1476.       do
  1477.       end /* otherwise */
  1478.  
  1479.     end /* select */
  1480.   end /* do forever */
  1481.  
  1482.                         /* close the window                           */
  1483.   RxDlg '"'optionWindowTitle'"' 4
  1484.  
  1485. RETURN
  1486.  
  1487. /* ------------------------------------------------------------------ */
  1488. /* GetIniFilePathDialog                                               */
  1489. /*                                                                    */
  1490. /* Function: Get the path for the ini file                            */
  1491. /*                                                                    */
  1492. /* Usage:    GetIniFilePathDialog                                     */
  1493. /*                                                                    */
  1494. /* where:    -                                                        */
  1495. /*                                                                    */
  1496. /* returns:  the path of the inifile or '' if aborted by the user     */
  1497. /*                                                                    */
  1498. /* note:     The path ends always with a backslash '\'.               */
  1499. /*           You can select the path from all a list containing       */
  1500. /*           - the current directory                                  */
  1501. /*           - the directory with REXXCC2.CMD                         */
  1502. /*           and                                                      */
  1503. /*           - all existing directorys from the environment variable  */
  1504. /*             DPATH (except the directorys on a "not ready" medium)  */
  1505. /*                                                                    */
  1506. GetIniFilePathDialog: PROCEDURE expose (exposeList)
  1507.  
  1508.                         /* init the return code                       */
  1509.   iniFilePath = ''
  1510.  
  1511.                         /* setup the stem with the possible pathes    */
  1512.   possiblePathes. = ' '
  1513.  
  1514.   i=1
  1515.   possiblePathes.i = translate( directory() )
  1516.  
  1517.   if prog.__Path <> possiblePathes.i  then
  1518.   do
  1519.     if DirExist( prog.__Path ) <> '' then
  1520.     do
  1521.       i=i+1
  1522.       possiblePathes.i = prog.__Path
  1523.     end /* if DirExist( prog.__Path ) <> '' then */
  1524.   end /* if ... */
  1525.                         /* get the current value of the environment   */
  1526.                         /* variable DPATH                             */
  1527.   dpathVar = value( 'DPATH' ,, prog.__env )
  1528.  
  1529.                         /* check each entry of the environment        */
  1530.                         /* variable DPATH and add it to the list      */
  1531.                         /* of possible directorys for the ini file    */
  1532.                         /* if the directory exist and is okay         */
  1533.   do until DPathVar = ''
  1534.     parse var DPathVar curDPathPart ';' DPathVar
  1535.     if curDpathPart <> '' then
  1536.     do
  1537.                     /* only add existing directorys to the list       */
  1538.       curDPathPart = DirExist( curDPathPart )
  1539.       if curDPathPart <> '' then
  1540.       do
  1541.         i=i+1
  1542.         possiblePathes.i = translate( curDPathPart )
  1543.       end /* if curDPathPart <> '' then */
  1544.     end /* if curDPathPart <> '' then */
  1545.     else
  1546.       if DPathVar <> '' then
  1547.         iterate
  1548.   end /* do until DPathVar = '' */
  1549.  
  1550.                   /* setup variables for the dialog to ask the user   */
  1551.  
  1552.                   /* title for the dialog                             */
  1553.   GetIniFileWindowTitle = prog.__vName prog.__Version || ' - Get IniFilepath'
  1554.  
  1555.   i = 0
  1556.  
  1557.   i = i+1;                      ; gif.__PathesText = i
  1558.   RXTYPE.i  = 'TEXT'
  1559.   RXFLAGS.i = ' '
  1560.   RXLABEL.i = 'Select a path for the ini file:'
  1561.   RXINFO.i  = '1 1'
  1562.   RXVAL.i   = ' '
  1563.   RXX.i     = 10
  1564.   RXY.i     = 150
  1565.  
  1566.   i = i+1;                      ; gif.__PathesListBox = i
  1567.   RXTYPE.i  = 'LIST'
  1568.   RXFLAGS.i = ' '
  1569.   RXLABEL.i = ' '
  1570.   RXINFO.i  = '1 1 511 6'
  1571.   RXVAL.i   = 'possiblePathes'
  1572.   RXX.i     = 10
  1573.   RXY.i     = 50
  1574.  
  1575.                   /* push buttons for the action                      */
  1576.   i=i+1                         ; gif.__ResultPushButtons = i
  1577.   RXTYPE.i  = 'RESULT'
  1578.   RXFLAGS.i = 'BOOL'
  1579.   RXLABEL.i = ' '
  1580.   RXINFO.i  = '1 2'
  1581.   RXVAL.i   = ' '
  1582.   RXX.i     = 60
  1583.   RXY.i     = 5
  1584.  
  1585.                           /* number of groups in this dialog          */
  1586.   noOfGroupsInGetIniFileWindow = i
  1587.  
  1588.                           /* show the dialog                          */
  1589.   RxDlg noOfGroupsInGetIniFileWindow ,
  1590.         '"'GetIniFileWindowTitle'"'  ,
  1591.         'WINDOW.__GETINIFILEWINDOWDIM'   ,
  1592.         'MODAL|KEYS|NOCLOSE'
  1593.  
  1594.                           /* (*?*) resize the LIST BOX                */
  1595.                           /* Note that the size for the LIST Box at   */
  1596.                           /* creation time is limited to 31           */
  1597.   rxSet '"'GetIniFileWindowTitle'"'  gif.__PathesListBox 1 'SIZE' 575
  1598.  
  1599.   do forever
  1600.  
  1601.  
  1602.                           /* perform user actions                     */
  1603.     RxDlg '"'GetIniFileWindowTitle'"' 0
  1604.  
  1605.                           /* update the REXX variables                */
  1606.     RxDlg '"'GetIniFileWindowTitle'"' 2
  1607.  
  1608.                         /* clear the PM message queue                 */
  1609.     RxDlg '""' 255
  1610.  
  1611.     /* -------------------- RETURN key processing ------------------- */
  1612.     if rxID = 0 & rxSubID = 10 then
  1613.     do
  1614.       rxID = gif.__ResultPushButtons
  1615.       rxVal.rxID = 1
  1616.     end /* if rxID = 0 & ... */
  1617.  
  1618.     if rxID = gif.__ResultPushButtons then
  1619.     do
  1620.       i = gif.__ResultPushButtons
  1621.  
  1622.     /* -------------------- OK push button -------------------------- */
  1623.       if RXVAL.i = 1 then
  1624.       do
  1625.         if possiblePathes.0 = '' then
  1626.           call ShowErrorMsg , 'Hey!: Either select a path for the inifile or press CANCEL to abort'
  1627.         else
  1628.         do
  1629.                       /* copy the selected PATH in the return code    */
  1630.                       /* variable                                     */
  1631.           iniFilePath = possiblePathes.0
  1632.  
  1633.                         /* add a trailing backslash if neccessary     */
  1634.           if right( iniFilePath,1 ) <> '\' then
  1635.             iniFilePath = iniFilePath || '\'
  1636.  
  1637.           leave
  1638.         end /* else */
  1639.       end /* if rxSubID = 1 then */
  1640.       else
  1641.         leave
  1642.     end /* if */
  1643.     else
  1644.       leave
  1645.   end /* do forever */
  1646.  
  1647.                           /* close the dialog                         */
  1648.   RxDlg '"'GetIniFileWindowTitle'"' 4
  1649.  
  1650. RETURN iniFilePath
  1651.  
  1652. /* ------------------------------------------------------------------ */
  1653. /* LoadSaveConfigData                                                 */
  1654. /*                                                                    */
  1655. /* Function: Load/Save the configuration data to/from the inifile     */
  1656. /*                                                                    */
  1657. /* Usage:    LoadSaveConfigData {action} , curIniFileName             */
  1658. /*                                                                    */
  1659. /* where:    action - action to take (LOAD or SAVE, def.: LOAD)       */
  1660. /*           curIniFileName - name & path of the ini file             */
  1661. /*                                                                    */
  1662. /* returns:  1 - ok, data loaded or saved                             */
  1663. /*           0 - loading or saving aborted by the user                */
  1664. /*          -1 - loading or saving aborted due to an error            */
  1665. /*                                                                    */
  1666. LoadSaveConfigData: PROCEDURE expose (exposeList)
  1667.   parse upper arg action , curIniFileName .
  1668.  
  1669.   thisRC = 1
  1670.  
  1671.   if action = 'SAVE' then
  1672.   do
  1673.                         /* save the config data to the ini file       */
  1674.     do i = 1
  1675.  
  1676.       if curIniFileName = '' | thisRC = -1 then
  1677.       do
  1678.         curIniFileName = ''
  1679.         tempStr = GetIniFilePathDialog()
  1680.         if tempStr <> '' then
  1681.            curIniFileName = tempStr || prog.__IniFileName
  1682.       end /* if curIniFileName = '' | ... */
  1683.  
  1684.       if curIniFileName = '' then
  1685.       do
  1686.                         /* saving aborted by the user                 */
  1687.         thisRC = 0
  1688.         leave i
  1689.       end
  1690.       else
  1691.       do
  1692.         if FileExist( curIniFileName ) <> 0 then
  1693.           if DriveReady( curIniFileName ) <> 1 then
  1694.             call ShowError, 'The drive ' || ,
  1695.                             substr( curIniFileName,1,2 ) || ,
  1696.                             ' is not ready'
  1697.           else
  1698.             tempRC = WriteReadtestIniFile( 'TEST', curIniFileName )
  1699.         else
  1700.           tempRC = 1
  1701.  
  1702.         if tempRC = -1 then
  1703.         do
  1704.           tempRC = ShowErrorMsg( 5, 'The format of the ini file ' || crlf || ,
  1705.                                     curIniFileName                || crlf || ,
  1706.                                     'is invalid. '                || crlf || ,
  1707.                                     'Press YES to overwrite the file' )
  1708.  
  1709.           select
  1710.  
  1711.             when tempRC = 6 then
  1712.             do
  1713.                         /* YES pressed                                */
  1714.  
  1715.                         /* delete the existing INI file               */
  1716.               rc = SysFileDelete( curIniFileName )
  1717.               if rc <> 0 & rc <> 2 then
  1718.               do
  1719.  
  1720.                 OS2Message = SysGetMessage( rc, 'OSO001.MSG', curIniFileName )
  1721.                     /* note: the dbrright call removes the trailing   */
  1722.                     /*       point and CR/LF from the message.        */
  1723.                 if OS2Message <> '' then
  1724.                   OS2Message = '(' || dbrright( OS2Message, 3 ) || ')'
  1725.  
  1726.                 rc = ShowErrorMsg( 1 , 'OS Error ' || rc || ' deleting the ini file.' || crLf || ,
  1727.                                        OS2Message )
  1728.                 if rc = 1 then
  1729.                   thisRC = -1
  1730.                 else
  1731.                 do
  1732.                         /* CANCEL pressed                             */
  1733.                   curIniFileName = ''
  1734.                   thisRC = 0
  1735.                   leave i
  1736.                 end /* else */
  1737.               end /* if rc <> 0 then */
  1738.               else
  1739.                 thisRC = 1
  1740.             end /* when */
  1741.  
  1742.             when tempRC = 7 then
  1743.             do
  1744.                         /* NO pressed                                 */
  1745.               thisRC = -1
  1746.             end /* when */
  1747.  
  1748.             when tempRC = 2 then
  1749.             do
  1750.                         /* ABORT pressed                              */
  1751.               curIniFileName = ''
  1752.               thisRC = 0
  1753.               leave i
  1754.             end /* when */
  1755.  
  1756.             otherwise
  1757.             do
  1758.                         /* unknown return code                        */
  1759.               thisRC = -1
  1760.             end /* when */
  1761.  
  1762.           end /* select */
  1763.  
  1764.         end /* if tempStr = '' then */
  1765.       end /* else */
  1766.  
  1767.       if curIniFileName <> '' & thisRC = 1 then
  1768.       do
  1769.                     /* write the configuration data to the ini file   */
  1770.         thisRC = WriteReadTestIniFile( 'SAVE', curIniFileName )
  1771.         if thisRC = 1 then
  1772.         do
  1773.           REXXCC2.__IniFileName = curIniFileName
  1774.           leave i
  1775.         end /* if ThisRC = 1 then */
  1776.         else
  1777.         do
  1778.           call ShowErrorMsg , 'Error saving the configuration data'
  1779.           curIniFileName = ''
  1780.           thisRC = 1
  1781.         end /* else */
  1782.       end /* if curIniFileName <> '' then */
  1783.  
  1784.     end /* do i = 1 */
  1785.  
  1786.   end /* if action = 'SAVE' then */
  1787.  
  1788.   else  /* action = 'LOAD' */
  1789.   do
  1790.                         /* load the config data from the ini file     */
  1791.  
  1792.     thisRC = -1         /* def.: error loading the inifile            */
  1793.  
  1794.     iniFileLoaded = 0
  1795.                         /* test & load the inifile                    */
  1796.     if DriveReady( curIniFileName ) <> 1 then
  1797.       call ShowErrorMsg , 'The drive ' || ,
  1798.                           substr( curIniFielName,1,2 ) || ,
  1799.                           ' is not ready'
  1800.     else
  1801.       if FileExist( curIniFileName ) = 0 then
  1802.         call ShowErrorMsg , 'The ini file ' || crlf || ,
  1803.                             curIniFileName  || crlf || ,
  1804.                             'does not yet exist'
  1805.  
  1806.       else
  1807.       do
  1808.         if WriteReadTestIniFile( 'TEST', curIniFileName ) = 1 then
  1809.           if WriteReadTestIniFile( 'LOAD', curIniFileName ) = 1 then
  1810.             iniFileLoaded = 1
  1811.  
  1812.         if iniFileLoaded = 1 then
  1813.         do
  1814.                         /* inifile loaded                             */
  1815.  
  1816.                         /* change the return code                     */
  1817.           thisRC = 1
  1818.                         /* change the global variable                 */
  1819.           REXXCC2.__IniFileName = curIniFileName
  1820.         end /* if iniFileLoaded = 1 then */
  1821.         else
  1822.         do
  1823.                         /* inifile format is invalid or error loading */
  1824.                         /* the inifile                                */
  1825.  
  1826.           call ShowErrorMsg , 'The format of the ini file ' || crlf || ,
  1827.                               curIniFileName                || crlf || ,
  1828.                               'is invalid'
  1829.         end /* else */
  1830.       end /* else */
  1831.   end /* else ACTION = 'LOAD' */
  1832.  
  1833. RETURN thisRC
  1834.  
  1835. /* ------------------------------------------------------------------ */
  1836. /* WriteReadTestIniFile                                               */
  1837. /*                                                                    */
  1838. /* Function: write, read or test the inifile                          */
  1839. /*                                                                    */
  1840. /* Usage:    WriteReadTestIniFile {action} , iniFileName              */
  1841. /*                                                                    */
  1842. /* where:    action - action to take:                                 */
  1843. /*                    LOAD, SAVE or TEST, def.: TEST                  */
  1844. /*                                                                    */
  1845. /* returns:  1 - ok, data written, read or tested                     */
  1846. /*           0 - file or application not found                        */
  1847. /*          -1 - error writing or reading the inifile, inifile        */
  1848. /*               is invalid or used by another process                */
  1849. /*                                                                    */
  1850. /*                                                                    */
  1851. WriteReadTestIniFile:
  1852.   parse arg action, iniFileName .
  1853.  
  1854.                         /* clear the PM message queue                 */
  1855.   RxDlg '""' 255
  1856.  
  1857.   action = strip( action )
  1858.   if action = '' then
  1859.     action = 'TEST'     /* default action is TEST                     */
  1860.  
  1861.  
  1862.                         /* setup the message for the status window    */
  1863.   select
  1864.  
  1865.     when action = 'LOAD' then
  1866.       actionMsg = 'Loading the inifile "' || ,
  1867.                   PackFileName( iniFileName, 30 ) || '" ...'
  1868.  
  1869.     when action = 'SAVE' then
  1870.       actionMsg = 'Writing the inifile "' || ,
  1871.                   PackFileName( iniFileName, 30 ) || '" ...'
  1872.  
  1873.     otherwise
  1874.       actionMsg = 'Testing the inifile "' || ,
  1875.                   PackFileName( iniFileName, 30 ) || '" ...'
  1876.  
  1877.   end /* select */
  1878.  
  1879.                         /* open the status window                     */
  1880.   call ShowStatusMsg 'OPEN', actionMsg '00'x 'Initialising ...'
  1881.  
  1882.  
  1883.                     /* default is: error processing the ini file      */
  1884.   thisRC = -1
  1885.  
  1886.                     /* separator for the fields in the ini file       */
  1887.                     /* values with more than one field                */
  1888.   fieldSep = '00'x
  1889.  
  1890.                     /* application name for the ini file              */
  1891.   appName = 'REXXCC/2'
  1892.  
  1893.                     /* name of the special key for the status of the  */
  1894.                     /* inifile                                        */
  1895.   statusKey = 'STATUS'
  1896.  
  1897.                     /* init the stem with the key names and values    */
  1898.   IniFileKeys.0 = 0             /* no. of keys                        */
  1899.  
  1900.   i=IniFileKeys.0
  1901.  
  1902.   i=i+1                         ; iniFileVersionIndex = i
  1903.                     /* name of the key                                */
  1904.   IniFileKeys.i.name    = 'INIFILEVERSION'
  1905.                     /* name of the corresponding REXX variable        */
  1906.   IniFileKeys.i.rexxVar = 'prog.__IniFileVersion'
  1907.  
  1908.   i=i+1
  1909.   IniFileKeys.i.Name    = 'COMPILERNAME'
  1910.   IniFileKeys.i.rexxVar = 'REXXCC2.__CompilerName'
  1911.  
  1912.   i=i+1
  1913.   IniFileKeys.i.Name    = 'EDITORNAME'
  1914.   IniFileKeys.i.rexxVar = 'REXXCC2.__EditorName'
  1915.  
  1916.   i=i+1
  1917.   IniFileKeys.i.Name    = 'DEFAULTTARGETDIR'
  1918.   IniFileKeys.i.rexxVar = 'REXXCC2.__DefaultTargetDir'
  1919.  
  1920.   i=i+1
  1921.   IniFileKeys.i.Name    = 'MODE'
  1922.   IniFileKeys.i.rexxVar = 'rexxcc.__mode'
  1923.  
  1924.   i=i+1
  1925.   IniFileKeys.i.Name    = 'REXXCC_OPTIONS'
  1926.   IniFileKeys.i.rexxVar = 'rexxcc.__Options'
  1927.  
  1928.   i=i+1
  1929.   IniFileKeys.i.Name    = 'LINECOUNT'
  1930.   IniFileKeys.i.rexxVar = 'rexxcc.__LineCount'
  1931.  
  1932.   i=i+1
  1933.   IniFileKeys.i.Name    = 'REXXCC2_OPTIONS'
  1934.   IniFileKeys.i.rexxVar = 'REXXCC2.__Options'
  1935.  
  1936.   i=i+1
  1937.   IniFileKeys.i.Name    = 'SOURCEFILES'
  1938.   IniFileKeys.i.rexxVar = 'sourceFiles.'
  1939.  
  1940.   i=i+1
  1941.   IniFileKeys.i.Name    = 'TARGETFILES'
  1942.   IniFileKeys.i.rexxVar = 'targetfiles.'
  1943.  
  1944.   i=i+1
  1945.   IniFileKeys.i.Name    = 'COPYRIGHTFILES'
  1946.   IniFileKeys.i.rexxVar = 'copyrightfiles.'
  1947.  
  1948.   i=i+1
  1949.   IniFileKeys.i.Name    = 'SOURCEFILES_CURPATH'
  1950.   IniFileKeys.i.rexxVar = 'sourceFiles.__Curpath'
  1951.  
  1952.   i=i+1
  1953.   IniFileKeys.i.Name    = 'TARGETFILES_CURPATH'
  1954.   IniFileKeys.i.rexxVar = 'targetfiles.__CurPath'
  1955.  
  1956.   i=i+1
  1957.   IniFileKeys.i.Name    = 'COPYRIGHTFILES_CURPATH'
  1958.   IniFileKeys.i.rexxVar = 'copyrightfiles.__CurPath'
  1959.  
  1960.   i=i+1
  1961.   IniFileKeys.i.Name    = 'COMPILECOMMANDS'
  1962.   IniFileKeys.i.rexxVar = 'compileCommands.'
  1963.  
  1964.   i=i+1
  1965.   IniFileKeys.i.Name    = 'MAINWINDOWDIM'
  1966.   IniFileKeys.i.rexxVar = 'window.__mainWindowDim'
  1967.  
  1968.   i=i+1
  1969.   IniFileKeys.i.Name    = 'OPTIONWINDOWDIM'
  1970.   IniFileKeys.i.rexxVar = 'window.__optionWindowDim'
  1971.  
  1972.   i=i+1
  1973.   IniFileKeys.i.Name    = 'GETINIFILEWINDOWDIM'
  1974.   IniFileKeys.i.rexxVar = 'window.__getiniFileWindowDim'
  1975.  
  1976.   i=i+1
  1977.   IniFileKeys.i.Name    = 'EDITCOMMANDWINDOWDIM'
  1978.   IniFileKeys.i.rexxVar = 'window.__EditCommandWindowDim'
  1979.  
  1980.   i=i+1
  1981.   IniFileKeys.i.Name    = 'COMPILESTATUSWINDOWDIM'
  1982.   IniFileKeys.i.rexxVar = 'window.__CompileStatusWindowDim'
  1983.  
  1984.   i=i+1
  1985.   IniFileKeys.i.Name    = 'STATUSWINDOWDIM'
  1986.   IniFileKeys.i.rexxVar = 'window.__StatusWindowDim'
  1987.  
  1988.                     /* correct the variable with the number of keys   */
  1989.   IniFileKeys.0 = i
  1990.  
  1991.                                 /* get the status of the ini file     */
  1992.   curStatus = 'ERROR:'
  1993.   testStem.0 = 0
  1994.  
  1995.                         /* clear the PM message queue                 */
  1996.   RxDlg '""' 255
  1997.  
  1998.   if FileExist( iniFileName ) = 0 then
  1999.     curStatus = 'FILENOTFOUND'
  2000.   else
  2001.     if SysIni( iniFileName, appName, 'ALL:', 'testStem' ) <> 'ERROR:' then
  2002.       if testStem.0 = 0 then
  2003.         curStatus = 'APPNOTFOUND'       /* application not found      */
  2004.       else
  2005.         curStatus = SysIni( iniFileName, appName, statusKey )
  2006.  
  2007.                         /* clear the PM message queue                 */
  2008.   RxDlg '""' 255
  2009.  
  2010.   select
  2011.                         /* CAUTION:                                   */
  2012.                         /*   DO NOT CHANGE THE SEQUENCE OF THE WHEN   */
  2013.                         /*   STATEMENTS!                              */
  2014.     when curStatus = 'ERROR:' then
  2015.     do
  2016.                         /* in case of an error do nothing             */
  2017.       nop
  2018.     end
  2019.  
  2020.     when action = 'SAVE' then
  2021.     do
  2022.  
  2023.                                 /* set the status of the ini file     */
  2024.       if SysIni( iniFileName, appName, statusKey, 'PENDING' ) = '' then
  2025.       do
  2026.  
  2027.         curSaveRC = ''
  2028.  
  2029.                          /* save the values                           */
  2030.         do i = 1 to IniFileKeys.0 while curSaveRC <> 'ERROR:'
  2031.  
  2032.                          /* update the status message                 */
  2033.           call ShowStatusMsg 'UPDATE', '=' '00'x ,
  2034.                              'Writing the key "' || iniFileKeys.i.name || '" ...'
  2035.  
  2036.                         /* clear the PM message queue                 */
  2037.           RxDlg '""' 255
  2038.  
  2039.                          /* create the value for the entry            */
  2040.           if right( IniFileKeys.i.rexxVar,1 ) <> '.' then
  2041.           do
  2042.                                 /* handle single variables            */
  2043.             curValue = value( IniFileKeys.i.rexxVar )
  2044.  
  2045.           end /* if right( IniFileKeys.i.rexxVar,1 ) <> '.' then */
  2046.           else
  2047.           do
  2048.                                 /* handle stem vars                   */
  2049.             curValue = ''
  2050.             do j = 1
  2051.                         /* clear the PM message queue                 */
  2052.               RxDlg '""' 255
  2053.  
  2054.               curSourceVarValue = value( IniFileKeys.i.rexxVar || j )
  2055.  
  2056.               if curSourceVarValue = '' then
  2057.                 leave
  2058.               else
  2059.                 curValue = curSourceVarValue || fieldSep || curValue
  2060.             end /* do j = 1 */
  2061.  
  2062.             curValue = j-1 || fieldSep || curValue
  2063.  
  2064.           end /* else */
  2065.  
  2066.  
  2067.           if curValue <> '' then
  2068.             curSaveRC = SysIni( iniFileName ,,
  2069.                                 appName ,,
  2070.                                 IniFileKeys.i.name ,,
  2071.                                 curValue )
  2072.           else
  2073.             call SysIni iniFileName, appName, IniFileKeys.i.name 'DELETE:'
  2074.  
  2075.                         /* clear the PM message queue                 */
  2076.           RxDlg '""' 255
  2077.  
  2078.         end /* do i = 1 to IniFileKeys.0 while ... */
  2079.  
  2080.         if curSaveRC <> 'ERROR:' then
  2081.         do
  2082.                           /* reset the status key of the ini file   */
  2083.           if SysIni( iniFileName, appName, statusKey, 'READY' ) = '' then
  2084.             thisRC = 1
  2085.         end  /* if curValue <> 'ERROR:' then */
  2086.         else
  2087.         do
  2088.               /* error saveing the inifile                          */
  2089.  
  2090.               /* delete the application from the inifile            */
  2091.           call SysIni iniFileName ,,
  2092.                        appName ,,
  2093.                        'DELETE:'
  2094.  
  2095.         end /* else */
  2096.       end /* if */
  2097.  
  2098.                         /* clear the PM message queue                 */
  2099.       RxDlg '""' 255
  2100.  
  2101.     end /* when */
  2102.  
  2103.     when curStatus = 'FILENOTFOUND' then
  2104.     do
  2105.                         /* we can't load or test a not existing file  */
  2106.       thisRC = 0
  2107.     end
  2108.  
  2109.     when curStatus = 'APPNOTFOUND' then
  2110.     do
  2111.                         /* it's also impossible to load or test an    */
  2112.                         /* ini file without the application key       */
  2113.       thisRC = 0
  2114.     end
  2115.  
  2116.     when action = 'LOAD' then
  2117.     do
  2118.  
  2119.                     /* set the status key of the ini file             */
  2120.       if SysIni( iniFileName, appName, statusKey, 'PENDING' ) = '' then
  2121.       do
  2122.  
  2123.                 /* reset all global variables to their default values */
  2124.         call InitVariables
  2125.  
  2126.         curValue = ''
  2127.  
  2128.                 /* read the values                                    */
  2129.         do i = 1 to IniFileKeys.0
  2130.  
  2131.                          /* update the status message                 */
  2132.           call ShowStatusMsg 'UPDATE', '=' '00'x ,
  2133.                              'Loading the key "' || iniFileKeys.i.name || '" ...'
  2134.  
  2135.                         /* clear the PM message queue                 */
  2136.           RxDlg '""' 255
  2137.  
  2138.           curValue = SysIni( iniFileName,,
  2139.                              appName,,
  2140.                              IniFileKeys.i.name )
  2141.  
  2142.           if curValue <> 'ERROR:' & curValue <> '' then
  2143.           do
  2144.             if right( IniFileKeys.i.rexxVar,1 ) <> '.' then
  2145.             do
  2146.                                 /* handle single variables            */
  2147.               iLine = IniFileKeys.i.rexxVar ' =  curValue '
  2148.               interpret iLine
  2149.             end /* if right( IniFileKeys.i.rexxVar,1 ) <> '.' then */
  2150.             else
  2151.             do
  2152.                                 /* handle stem vars                   */
  2153.  
  2154.                                 /* get the number of fields           */
  2155.               parse var curValue curValueCount (fieldSep) curValue
  2156.  
  2157.                     /* copy the field values into the REXX variables  */
  2158.               do j = 1 to curValueCount
  2159.  
  2160.                         /* clear the PM message queue                 */
  2161.                 RxDlg '""' 255
  2162.  
  2163.                 parse var curValue curFieldValue (fieldSep) curValue
  2164.                 iLine = iniFilekeys.i.rexxVar || j ' = curFieldValue '
  2165.                 interpret iLine
  2166.               end /* do j = 1 to curValueCount */
  2167.  
  2168.             end /* else */
  2169.           end /* if curValue <> 'ERROR:' then */
  2170.         end /* do i = 1 to IniFileKeys.0 */
  2171.  
  2172.                             /* reset the status key of the ini file   */
  2173.         if SysIni( iniFileName, appName, statusKey, 'READY' ) = '' then
  2174.           thisRC = 1
  2175.  
  2176.       end /* if SysIni( ... */
  2177.  
  2178.                         /* clear the PM message queue                 */
  2179.       RxDlg '""' 255
  2180.  
  2181.     end /* when */
  2182.  
  2183.     when action = 'TEST' then
  2184.     do
  2185.                     /* check the version of the ini file              */
  2186.       i = IniFileVersionIndex
  2187.       curIniFileVersion = SysIni( iniFileName, appName, IniFileKeys.i.name )
  2188.  
  2189.       if curIniFileVersion <> '' & curIniFileVersion <= value( IniFileKeys.i.rexxVar ) then
  2190.         thisRC = 1
  2191.                         /* clear the PM message queue                 */
  2192.       RxDlg '""' 255
  2193.  
  2194.     end /* when */
  2195.  
  2196.     otherwise
  2197.       nop
  2198.  
  2199.   end /* select */
  2200.  
  2201.                         /* close the status window                    */
  2202.   call ShowStatusMsg 'CLOSE'
  2203.  
  2204.                         /* clear the PM message queue                 */
  2205.   RxDlg '""' 255
  2206.  
  2207. RETURN thisRC
  2208.  
  2209. /* ------------------------------------------------------------------ */
  2210. /* StartCompile                                                       */
  2211. /*                                                                    */
  2212. /* Function: Start the compiler                                       */
  2213. /*                                                                    */
  2214. /* Usage:    StartCompile                                             */
  2215. /*                                                                    */
  2216. /* where:    -                                                        */
  2217. /*                                                                    */
  2218. /* returns:  returncode of REXXCC or -1 in case of an error           */
  2219. /*                                                                    */
  2220. StartCompile: PROCEDURE expose (exposeList)
  2221.  
  2222.                         /* init the return code                       */
  2223.   thisRC = -1
  2224.  
  2225.                         /* create the command to compile              */
  2226.   compileCommand = ''
  2227.  
  2228.   if sourceFiles.0 <> '' then
  2229.     compileCommand = compileCommand || sourceFiles.0
  2230.  
  2231.   if targetFiles.0 <> '' then
  2232.     compileCommand = compileCommand || ' TO ' || targetFiles.0
  2233.  
  2234.   if copyrightFiles.0 <> '' then
  2235.     compileCommand = compileCommand || ' WITH ' || copyrightFiles.0
  2236.  
  2237.   if REXXCC.__Mode = 1 then
  2238.     compileCommand = compileCommand || ' /compress'
  2239.  
  2240.   REXXCCSwitches = '/AddCode /IDate /IVer /IExt /Overwrite /UseSource /CMode /ShowDate'
  2241.  
  2242.   do i = 1 to words( REXXCC.__Options )
  2243.     curIndex = word( REXXCC.__Options, i )
  2244.     compileCommand = compileCommand word( REXXCCSwitches, curIndex )
  2245.   end /* do i = 1 to ... */
  2246.  
  2247.   if REXXCC.__LineCount <> 0 then
  2248.     compileCommand = compileCommand '/LineCount=' || REXXCC.__LineCount
  2249.  
  2250.                         /* doCompile = 1 -> start the compiler        */
  2251.   doCompile = 1
  2252.  
  2253.   if wordPos( '3', REXXCC2.__Options ) <> 0 then
  2254.   do
  2255.                         /* edit the command before executing it       */
  2256.  
  2257.     EditCommandWindowTitle = prog.__vName || ' - Edit the compile command'
  2258.     i = 0
  2259.  
  2260.     i = i+1;                    ; ecw.__EditField = 1
  2261.     RXTYPE.i  = 'DROP'
  2262.     RXFLAGS.i = ' '
  2263.     RXLABEL.i = 'Compile command:'
  2264.     RXINFO.1  = '1 1 511'
  2265.     RXVAL.i   = 'CompileCommands'
  2266.     RXX.i     = 175
  2267.     RXY.i     = 50
  2268.  
  2269.     i = i+1                     ; ecw.__ResultPushButtons = i
  2270.     RXTYPE.i  = 'RESULT'
  2271.     RXFLAGS.i = 'BOOL'
  2272.     RXLABEL.i = ' '
  2273.     RXINFO.i  = '1 2'
  2274.     RXVAL.i   = ' '
  2275.     RXX.i     = 225
  2276.     RXY.i     = 5
  2277.  
  2278.                           /* number of groups in this dialog          */
  2279.     noOfGroupsinEditCmdWindow = i
  2280.  
  2281.                           /* show the dialog                          */
  2282.     RxDlg noOfGroupsInEditCmdWindow ,
  2283.           '"'EDITCOMMANDWINDOWTITLE'"'  ,
  2284.           'WINDOW.__EDITCOMMANDWINDOWDIM' ,
  2285.           'MODAL|KEYS|NOCLOSE'
  2286.  
  2287.                             /* insert the command into the input box  */
  2288.     RxSet '"'EditCommandWindowTitle'"' ecw.__EditField 1 'VAL' compileCommand
  2289.  
  2290.                             /* change the size of the drop down box   */
  2291.                         /* (*?*) this is neccessary because the       */
  2292.                         /* initial size of the fields is limited      */
  2293.     RxSet '"'EditCommandWindowTitle'"' ecw.__EditField 1 'SIZE' 480
  2294.  
  2295.  
  2296.     do forever
  2297.  
  2298.                             /* perform user actions                   */
  2299.       RxDlg '"'EditCommandWindowTitle'"' 0
  2300.  
  2301.                             /* update REXX variables                  */
  2302.       RxDlg '"'EditCommandWindowTitle'"' 2
  2303.  
  2304.                         /* clear the PM message queue                 */
  2305.       RxDlg '""' 255
  2306.  
  2307.       /* ------------------ RETURN key processing ------------------- */
  2308.       if rxID = 0 & rxSubID = 10 then
  2309.       do
  2310.         rxID = ecw.__ResultPushButtons
  2311.         rxVal.rxID = 1
  2312.       end /* if rxID = 0 & ... */
  2313.  
  2314.       /* -------------------- Result push buttons ------------------- */
  2315.       if rxID = ecw.__ResultPushButtons then
  2316.       do
  2317.         i = ecw.__ResultPushButtons
  2318.  
  2319.         select
  2320.           /* --------------- CANCEL push button --------------------- */
  2321.           when RXVAL.i = 0 then
  2322.             doCompile = 0
  2323.  
  2324.           /* --------------- OK push button ------------------------- */
  2325.           when RXVAL.i = 1 then
  2326.             CompileCommand = CompileCommands.0
  2327.         end /* select */
  2328.  
  2329.         leave
  2330.       end /* if */
  2331.     end /* do forever */
  2332.  
  2333.                             /* close the dialog                       */
  2334.     RxDlg '"'EditCommandWindowTitle'"' 4
  2335.  
  2336.   end /* if wordPos( ... */
  2337.  
  2338.   if doCompile = 1 then
  2339.   do
  2340.  
  2341.                         /* check if this command is already in the    */
  2342.                         /* stem with the already executed compile     */
  2343.                         /* commands                                   */
  2344.     addCommand = ( CompileCommand <> '' )
  2345.     do i = 1 while CompileCommands.i <> '' & addCommand = 1
  2346.       if translate( CompileCommands.i ) = translate( CompileCommand ) then
  2347.         addCommand = 0
  2348.     end /* do */
  2349.  
  2350.     if addCommand = 1 then
  2351.     do
  2352.                         /* add the command to the stem with the       */
  2353.                         /* already executed compile commands          */
  2354.       CompileCommands.i = CompileCommand
  2355.     end /* if addCommand = 1 then */
  2356.  
  2357.     CompileCommand = REXXCC2.__CompilerName ' ' compileCommand
  2358.  
  2359.                         /* flush the queue                            */
  2360.     do while queued() <> 0
  2361.                         /* clear the PM message queue                 */
  2362.       RxDlg '""' 255
  2363.  
  2364.       pull queue
  2365.     end /* do while queued() <> 0 */
  2366.  
  2367.                         /* temporary set the environment variable     */
  2368.                         /* ANSI to 'OFF'                              */
  2369.     ansiVarValue = value( 'ANSI', 'OFF', prog.__env )
  2370.  
  2371.                         /* temporary delete the environment variable  */
  2372.                         /* REXXCC if neccessary                       */
  2373.     if wordPos( '2', REXXCC2.__Options ) <> 0 then
  2374.       envVarValue = value( 'REXXCC', '', prog.__env )
  2375.  
  2376.                         /* init the stem for the message of REXXCC    */
  2377.     REXXCCOutput. = ' '
  2378.  
  2379.     CompileStatusWindowTitle = prog.__vName || ' - REXXCC Compile status'
  2380.  
  2381.     i = 0
  2382.  
  2383.     i = i+1                       ; csw.__StatustextField = i
  2384.     RXTYPE.i  = 'TEXT'
  2385.     RXFLAGS.i = ' '
  2386.     RXLABEL.i = 'Status: Calling the compiler ... '
  2387.     RXINFO.i  = '1 1 511 1'
  2388.     RXVAL.i   = ' '
  2389.     RXX.i     = 10
  2390.     RXY.i     = 200
  2391.  
  2392.     i=i+1;                        ; csw.__ResultListBox = i
  2393.     RXTYPE.i  = 'LIST'
  2394.     RXFLAGS.i = ' '
  2395.     RXLABEL.i = ' '
  2396.     RXINFO.i  = '1 1 510 10'
  2397.     RXVAL.i   = 'REXXCCOutput'
  2398.     RXX.i     = 10
  2399.     RXY.i     = 35
  2400.  
  2401.  
  2402.     i=i+1;                        ; csw.__ResultPushButtons = i
  2403.     RXTYPE.i  = 'PUSH'
  2404.     RXFLAGS.i = 'END'
  2405.     RXLABEL.i = 'OK'
  2406.     RXINFO.i  = '1 1 0'
  2407.     RXVAL.i   = '1'
  2408.     RXX.i     = 335
  2409.     RXY.i     = 5
  2410.  
  2411.     noOfGroupsInCompileStatusWin = i
  2412.  
  2413.                         /* show the compile status window             */
  2414.     RxDlg noOfGroupsInCompileStatusWin   ,
  2415.           '"'compileStatusWindowTitle'"' ,
  2416.           'WINDOW.__COMPILESTATUSWINDOWDIM' ,
  2417.           'NOCLOSE|MODAL|KEYS|RESULT'
  2418.  
  2419.                         /* hide the OK button                         */
  2420.     RxSet '"'compileStatusWindowTitle'"' csw.__ResultPushButtons 1 'HIDE'
  2421.  
  2422.                         /* change the size of the status text field   */
  2423.                         /* (*?*) this is neccessary because the       */
  2424.                         /* initial size of the fields is limited      */
  2425.     RxSet '"'compileStatusWindowTitle'"' csw.__StatusTextField 1 'SIZE' 675
  2426.  
  2427.                         /* (*?*) resize the LIST BOX                  */
  2428.                         /* Note that the size for the LIST Box at     */
  2429.                         /* creation time is limited to 31             */
  2430.     rxSet '"'compileStatusWindowTitle'"'  csw.__ResultListBox 1  'SIZE' 675
  2431.  
  2432.                         /* update the window contents                 */
  2433.     RxDlg '"'compileStatusWindowTitle'"' 255
  2434.  
  2435.                         /* clear the PM message queue                 */
  2436.     RxDlg '""' 255
  2437.  
  2438.                         /* set the timeout for the window             */
  2439.                         /* (value in milliseconds)                    */
  2440.     rxSet '"'compileStatusWindowTitle'"' 'TIME' 100
  2441.  
  2442.     ADDRESS 'CMD' 'detach ' CompileCommand '2>&1 | rxqueue '
  2443.  
  2444.                         /* returncode of REXXCC: 0 = okay, else error */
  2445.     REXXCC.__rc = 255
  2446.  
  2447.                         /* if not zero REXXCC has ended               */
  2448.     REXXCCEnded = 0
  2449.  
  2450.                         /* if zero we need to update the status line  */
  2451.     StatusUpdated = 0
  2452.  
  2453.                         /* help variable to check if REXXCC has ended */
  2454.     SecondProcessTimeOut = 5000
  2455.  
  2456.     do forever
  2457.                         /* update the status line and show the OK     */
  2458.                         /* button if REXXCC has ended                 */
  2459.       if (REXXCCEnded <> 0) & (StatusUpdated = 0) then
  2460.       do
  2461.                         /* correct the status line                    */
  2462.         if REXXCC.__rc = 0 then
  2463.           rxSet '"'compileStatusWindowTitle'"' csw.__StatustextField 1 'VAL' ,
  2464.                 'Status: Succesfully compiled.'
  2465.         else
  2466.           rxSet '"'compileStatusWindowTitle'"' csw.__StatustextField 1 'VAL' ,
  2467.                 'Status: Compiling endet with an error.'
  2468.  
  2469.                         /* stop the timeout timer                     */
  2470.         rxSet '"'compileStatusWindowTitle'"' 'TIME' 0
  2471.  
  2472.                         /* unhide the OK button                       */
  2473.         RxSet '"'compileStatusWindowTitle'"' csw.__ResultPushButtons 1 'SHOW'
  2474.  
  2475.         StatusUpdated = 1
  2476.       end /* if REXXCCEnded <> 0 & ... */
  2477.  
  2478.                         /* perform user actions                       */
  2479.       RxDlg '"'compileStatusWindowTitle'"' 0
  2480.  
  2481.       select
  2482.  
  2483.         /* ---------------- time out action ------------------------- */
  2484.         when rxID = 0 & rxSubID = 0 then
  2485.         do
  2486.           if queued() = 0 then
  2487.           do
  2488.  
  2489.                         /* check for a timeOut                        */
  2490.             SecondProcessTimeOut = SecondProcessTimeOut -1
  2491.             if SecondProcessTimeOut <= 0 then
  2492.             do
  2493.                         /* set marker that REXXCC has ended           */
  2494.               REXXCCEnded = 1
  2495.             end /* if ... */
  2496.             else
  2497.             do
  2498.               RxSet '"'compileStatusWindowTitle'"' csw.__StatustextField 1 'VAL' ,
  2499.                     'Status: Calling the compiler ... (TimeOut = ' || SecondProcessTimeOut || ')'
  2500.             end /* else */
  2501.  
  2502.           end /* if queued() = 0 then */
  2503.           else
  2504.           do
  2505.                         /* get the output from REXXCC and insert it   */
  2506.                         /* into the list dialog                       */
  2507.             iLine = lineIN( 'QUEUE:' )
  2508.             if pos( 'successfully created' , iLine ) <> 0 then
  2509.               REXXCC.__rc = 0
  2510.  
  2511.                         /* check if REXXCC has ended                  */
  2512.             if pos( 'ended on' , iLine ) <> 0 then
  2513.               REXXCCEnded = 1
  2514.  
  2515.             if pos( 'lost it''s extended attributes', iLine ) <> 0 then
  2516.               REXXCCEnded = 1
  2517.  
  2518.             do until iLine = ''
  2519.               tempStr = substr( iLine,1,80 )
  2520.               iLine = substr( iLine, 81 )
  2521.               rxSet '"'compileStatusWindowTitle'"' csw.__ResultListBox 1 'ADD ' tempStr '|' '-1'
  2522.               i = i +1
  2523.  
  2524.                         /* update the window contents                 */
  2525.               RxDlg '"'compileStatusWindowTitle'"' 255
  2526.  
  2527.                         /* clear the PM message queue                 */
  2528.               RxDlg '""' 255
  2529.  
  2530.             end /* do until iLine = '' */
  2531.  
  2532.           end /* else */
  2533.  
  2534.                         /* set the timeout for the window again if    */
  2535.                         /* neccessary (value in milliseconds)         */
  2536.           if REXXCCEnded <> 0 then
  2537.             rxSet '"'compileStatusWindowTitle'"' 'TIME' 100
  2538.         end /* when */
  2539.  
  2540.         /* ---------------- OK button ------------------------------- */
  2541.         when rxID > 0 then
  2542.         do
  2543.           if REXXCCEnded <> 0 then
  2544.             leave
  2545.         end /* when */
  2546.  
  2547.         /* ---------------- misc. events ---------------------------- */
  2548.         otherwise
  2549.         do
  2550.           if REXXCCEnded <> 0 then
  2551.             leave
  2552.         end /* when */
  2553.       end /* select */
  2554.     end /* do forever */
  2555.  
  2556.                         /* close the dialog                           */
  2557.     RxDlg '"'compileStatusWindowTitle'"' 4
  2558.  
  2559.                         /* restore the environment variable           */
  2560.                         /* REXXCC if neccessary                       */
  2561.     if wordPos( '2', REXXCC2.__Options ) <> 0 then
  2562.       envVarValue = value( 'REXXCC', envVarValue, prog.__env)
  2563.  
  2564.                         /* restore the environment variable ANSI      */
  2565.     ansiVarValue = value( 'ANSI', ansiVarValue, prog.__env )
  2566.  
  2567.                         /* flush the queue if neccessary              */
  2568.     do while queued() <> 0
  2569.       pull queue
  2570.                         /* clear the PM message queue                 */
  2571.       RxDlg '""' 255
  2572.  
  2573.     end /* do while queued() <> 0 */
  2574.  
  2575.   end /* if doCompile = 1 then */
  2576.  
  2577. RETURN thisRC
  2578.  
  2579. /* ------------------------------------------------------------------ */
  2580. /* ClearFileLists                                                     */
  2581. /*                                                                    */
  2582. /* Function: Clear the filelists & the command history                */
  2583. /*                                                                    */
  2584. /* Usage:    ClearFileLists                                           */
  2585. /*                                                                    */
  2586. /* where:    -                                                        */
  2587. /*                                                                    */
  2588. /* returns:  1 - filelists & command history cleared                  */
  2589. /*           0 - operation aborted by the user                        */
  2590. /*                                                                    */
  2591. ClearFileLists:
  2592.   thisRC = 0
  2593.   rxSay 'Clear all 3 filelists and the command history?' '|' 4+16  'Warning'
  2594.  
  2595.   if rc = 6 then
  2596.   do
  2597.                         /* clear the drop down boxes                  */
  2598.     RxSet '"'MainWindowTitle'"' md.__SourceFileDropBox    1 'DEL'
  2599.     RxSet '"'MainWindowTitle'"' md.__TargetFileDropbox    1 'DEL'
  2600.     RxSet '"'MainWindowTitle'"' md.__CopyrightFileDropBox 1 'DEL'
  2601.  
  2602.                         /* clear the REXX variables                   */
  2603.     SourceFiles. = ' '
  2604.     targetFiles. = ' '
  2605.     copyrightFiles. = ' '
  2606.     CompileCommands. = ' '
  2607.  
  2608.     thisRC = 1
  2609.   end /* if rc = 0 then */
  2610.  
  2611. RETURN thisRC
  2612.  
  2613. /* ------------------------------------------------------------------ */
  2614. /* function: Search a file in the current directory and in the        */
  2615. /*           directorys saved in an environment variable              */
  2616. /*           (e.g. PATH, DPATH, ... )                                 */
  2617. /*                                                                    */
  2618. /* call:     SearchFile( fileName, varName {,environment})            */
  2619. /*                                                                    */
  2620. /* where:    fileName - name of the file to search                    */
  2621. /*           varName - name of the environment variable containing    */
  2622. /*                     the directorys to search (e.g. PATH)           */
  2623. /*           environment - environment with the environment Variable  */
  2624. /*                         (Def.: OS2ENVIRONMENT)                     */
  2625. /*                                                                    */
  2626. /* returns:  fully qualified name of the file or "" if not found      */
  2627. /*                                                                    */
  2628. SearchFile: PROCEDURE expose (exposeList)
  2629.   parse arg fileName , envVar, environment
  2630.   resultStr = ""
  2631.  
  2632.   if fileName <> "" & envVar <> "" then
  2633.   do
  2634.     if environment = '' then
  2635.       environment = "OS2ENVIRONMENT"
  2636.  
  2637.                 /* insert the current directory in the path variable  */
  2638.     searchDirs = ".;" || value( envVar, , environment )
  2639.  
  2640.     do forever
  2641.       parse var searchDirs curSearchDir ";" searchDirs
  2642.  
  2643.       curSearchDir = strip( curSearchDir )
  2644.  
  2645.       if curSearchDir = "" then
  2646.         iterate
  2647.  
  2648.       if right( curSearchDir, 1 ) <> "\" & ,
  2649.          right( curSearchDir, 1 ) <> ":" then
  2650.         curSearchDir = curSearchDir || "\"
  2651.  
  2652.       if FileExist( curSearchDir || fileName ) >= 1 then
  2653.       do
  2654.         resultStr = curSearchDir || fileName
  2655.         leave
  2656.       end
  2657.  
  2658.       if SearchDirs = "" then
  2659.         leave           /* file not found                             */
  2660.  
  2661.     end /* do forverver */
  2662.   end /* if fileName <> "" & ... */
  2663.  
  2664.   if resultStr <> '' then
  2665.     resultStr = stream( resultStr, 'c', 'QUERY EXIST' )
  2666.  
  2667. RETURN resultStr
  2668.  
  2669. /* ------------------------------------------------------------------ */
  2670. /* function: Check if a file exists (finds also hidden, read-only and */
  2671. /*           system files)                                            */
  2672. /*                                                                    */
  2673. /* call:     FileExist( fileName )                                    */
  2674. /*                                                                    */
  2675. /* where:    fileName - name of the file to search (joker are allowed)*/
  2676. /*                                                                    */
  2677. /* returns:  0 - file does not exist                                  */
  2678. /*           else returning the number of files found                 */
  2679. /*                                                                    */
  2680. FileExist: PROCEDURE expose (exposeList)
  2681.   parse arg fileName
  2682.  
  2683.   if substr( fileName,2,1 ) = ':' then
  2684.     thisRC = DriveReady( fileName )
  2685.   else
  2686.     thisRC = 1
  2687.  
  2688.   if thisRC = 1 then
  2689.   do
  2690.     searchRC = SysFileTree( fileName , 'fileStem', 'FO' )
  2691.     if searchRC = 0 then
  2692.       thisRC = fileStem.0
  2693.     else
  2694.       thisRC = 0
  2695.   end /* if thisRC = 1 then */
  2696.  
  2697. RETURN thisRC
  2698.  
  2699. /* ------------------------------------------------------------------ */
  2700. /* function: Search a file in the current directory and in the        */
  2701. /*           directorys saved in the environment variable PATH        */
  2702. /*                                                                    */
  2703. /* call:     SearchProgram( progName {,environment})                  */
  2704. /*                                                                    */
  2705. /* where:    progName - name of the program to search                 */
  2706. /*           environment - environment with the environment Variable  */
  2707. /*                         (Def.: OS2ENVIRONMENT)                     */
  2708. /*                                                                    */
  2709. /* returns:  full name of the program or "" if not found              */
  2710. /*                                                                    */
  2711. SearchProgram: PROCEDURE expose (exposeList)
  2712.   parse arg progName , environment
  2713.   resultStr = ""
  2714.   if progName <> "" then
  2715.     resultStr = SearchFile( progName, "PATH", environment )
  2716. RETURN resultStr
  2717.  
  2718. /* ------------------------------------------------------------------ */
  2719. /* function: Search a datafile in the current directory and in the    */
  2720. /*           directorys saved in the environment variable DPATH       */
  2721. /*                                                                    */
  2722. /* call:     SearchProgram( datafileName {,environment})              */
  2723. /*                                                                    */
  2724. /* where:    datafileName - name of the datafile to search            */
  2725. /*           environment - environment with the environment Variable  */
  2726. /*                         (Def.: OS2ENVIRONMENT)                     */
  2727. /*                                                                    */
  2728. /* returns:  full name of the datafile or "" if not found             */
  2729. /*                                                                    */
  2730. SearchDataFile: PROCEDURE expose (exposeList)
  2731.   parse arg dataFileName , environment
  2732.   resultStr = ""
  2733.   if dataFileName <> "" then
  2734.     resultStr = SearchFile( datafileName, "DPATH", environment )
  2735. RETURN resultStr
  2736.  
  2737. /* ------------------------------------------------------------------ */
  2738. /* function: extended FILESPEC function                               */
  2739. /*                                                                    */
  2740. /* call:     FileSpec option,fileName                                 */
  2741. /*                                                                    */
  2742. /* where:    option                                                   */
  2743. /*             - E{xtension}                                          */
  2744. /*               return the extension of the file                     */
  2745. /*             All other values for "option" are processed by the     */
  2746. /*             original FILESPEC function.                            */
  2747. /*           fileName                                                 */
  2748. /*             - name of the file                                     */
  2749. /*                                                                    */
  2750. /* returns:  if option = E{xtension}:                                 */
  2751. /*             the extension of the fileName or "" if none            */
  2752. /*           else                                                     */
  2753. /*             the return code of the original FILESPEC function      */
  2754. /*             or "SYNTAX ERROR" if called with invalid parameter(s)  */
  2755. /*                                                                    */
  2756. /* note:     To call the original FILESPEC function direct use        */
  2757. /*             myResult = "FILESPEC"( option, fileName )              */
  2758. /*                                                                    */
  2759. FileSpec: PROCEDURE
  2760.   parse arg option, fileName
  2761.  
  2762.                         /* init the return code                       */
  2763.   rc = "SYNTAX ERROR"
  2764.                         /* install a local error handler              */
  2765.   SIGNAL ON SYNTAX NAME FileSpecError
  2766.  
  2767.   option = translate( strip( option ) )
  2768.                         /* check the option code                      */
  2769.   if abbrev( "EXTENSION", option ) = 1 then
  2770.   do
  2771.                         /* process the new added option code          */
  2772.     i = lastPos( ".", fileName )
  2773.     if i > lastPos( "\", fileName ) then
  2774.       rc = substr( fileName, i+1 )
  2775.     else
  2776.       rc = ""
  2777.   end
  2778.   else                  /* call the original FILESPEC function        */
  2779.     rc = "FILESPEC"( option, fileName )
  2780.  
  2781. FileSpecError:
  2782.  
  2783. RETURN rc
  2784.  
  2785. /* ------------------------------------------------------------------ */
  2786. /* function: test if a directory exist                                */
  2787. /*                                                                    */
  2788. /* call:     DirExist( testDir )                                      */
  2789. /*                                                                    */
  2790. /* where:    testDir - name of the directory to test                  */
  2791. /*                                                                    */
  2792. /* returns:  full name of the directory or "" if the directory        */
  2793. /*           don't exist                                              */
  2794. /*                                                                    */
  2795. DirExist: PROCEDURE expose (exposeList)
  2796.   parse arg testDir .
  2797.  
  2798.                         /* init the return code                       */
  2799.   thisRC = ""
  2800.  
  2801.                         /* install a temporary error handler to check */
  2802.                         /* if the drive with the directory to test is */
  2803.                         /* ready                                      */
  2804.   SIGNAL ON NOTREADY NAME DirDoesNotExist
  2805.  
  2806.                         /* check if the drive is ready                */
  2807.   call stream testDir || "*", "D"
  2808.  
  2809.                         /* save the current directory of the current  */
  2810.                         /* drive                                      */
  2811.   curDir = directory()
  2812.  
  2813.                         /* save the current directory of the drive    */
  2814.                         /* with the directory to test                 */
  2815.   curDir1 = directory( fileSpec( "drive", testDir ) )
  2816.  
  2817.                         /* test if the directory exist                */
  2818.   thisRC = directory( testDir )
  2819.  
  2820.                         /* restore the current directory of the drive */
  2821.                         /* with the directory to test                 */
  2822.   call directory curDir1
  2823.  
  2824.                         /* restore the current directory of the       */
  2825.                         /* current drive                              */
  2826.   call directory curDir
  2827. DirDoesNotExist:
  2828.  
  2829. return thisRC
  2830.  
  2831. /* ------------------------------------------------------------------ */
  2832. /* PackFileName                                                       */
  2833. /*                                                                    */
  2834. /* Function: convert a filename to a given length                     */
  2835. /*                                                                    */
  2836. /* Usage:    PackFileName filename, fieldLength                       */
  2837. /*                                                                    */
  2838. /* where:    filename - the name of the file                          */
  2839. /*           fieldLength - the field length                           */
  2840. /*                                                                    */
  2841. /* returns:  nothing                                                  */
  2842. /*                                                                    */
  2843. PackFileName: PROCEDURE expose (exposeList)
  2844.   parse arg fileName, fieldLength
  2845.  
  2846.   fileName = strip( fileName )
  2847.  
  2848.   if length( fileName ) > fieldLength then
  2849.   do
  2850.     if substr( fileName, 2, 1 ) = ':' then
  2851.       resStr = substr( fileName,1,3 ) || '...' ||,
  2852.                substr( fileName, length( fileName ) - fieldLength + 6 )
  2853.     else
  2854.       resStr = '...' || substr( fileName, length( fileName ) - fieldLength + 3 )
  2855.   end
  2856.   else
  2857.     resStr = fileName
  2858.  
  2859. RETURN resStr
  2860.  
  2861. /* ------------------------------------------------------------------ */
  2862. /* CheckCompiler                                                      */
  2863. /*                                                                    */
  2864. /* Function: checks if a compiler is valid                            */
  2865. /*                                                                    */
  2866. /* Usage:    CheckCompiler compilerName                               */
  2867. /*                                                                    */
  2868. /* where:    compilerName - name of the compiler                      */
  2869. /*                                                                    */
  2870. /* returns:  1 - ok                                                   */
  2871. /*           0 - no                                                   */
  2872. /*                                                                    */
  2873. /* notes:    This function checks the extension of the program and    */
  2874. /*           the EAs.                                                 */
  2875. /*                                                                    */
  2876. CheckCompiler: PROCEDURE expose (exposeList)
  2877.   parse upper arg compilerName .
  2878.   thisRC = 0
  2879.  
  2880.   if compilerName <> '' then
  2881.     if stream( compilerName, 'c', 'QUERY EXIST' ) <> '' then
  2882.       if fileSpec( 'E', compilerName ) = 'CMD' then
  2883.  
  2884.         if SysGetEA( compilerName, 'REXX.LITERALPOOL', 'EA.__REXXLiteralPool' ) = 0 then
  2885.           if length( EA.__RexxLiteralPool ) >= 8700 then
  2886.  
  2887.             if SysGetEA( compilerName, 'REXX.METACONTROL', 'EA.__REXXMetaControl' ) = 0 then
  2888.               if length( EA.__RexxMetaControl ) >= 68 then
  2889.  
  2890.                 if SysGetEA( compilerName, 'REXX.TOKENSIMAGE', 'EA.__REXXTokensImage' ) = 0 then
  2891.                   if length( EA.__RexxTokensImage ) >= 51500 then
  2892.  
  2893.                     if SysGetEA( compilerName, 'REXX.VARIABLEBUF', 'EA.__REXXVariableBuf' ) = 0 then
  2894.                       if length( EA.__RexxVariableBuf ) >= 3500 then
  2895.                         thisRC = 1
  2896. RETURN thisRC
  2897.  
  2898. /* ------------------------------------------------------------------ */
  2899. /* ShowStatusMsg                                                      */
  2900. /*                                                                    */
  2901. /* Function: shows, updates or closes a status window                 */
  2902. /*                                                                    */
  2903. /* Usage:    ShowStatusMsg OPEN, statusMsg1 '00'x statusMsg2          */
  2904. /*           ShowStatusMsg UPDATE, newStatuMsg1 '00'x newStatusMsg2   */
  2905. /*           ShowStatusMsg CLOSE                                      */
  2906. /*                                                                    */
  2907. /* where:    -                                                        */
  2908. /*                                                                    */
  2909. /* returns:  -                                                        */
  2910. /*                                                                    */
  2911. /* Note:     Use '=' if you don't want to overwrite the previous      */
  2912. /*           statusMsg.                                               */
  2913. /*                                                                    */
  2914. ShowStatusMsg: PROCEDURE expose (exposeList)
  2915.   parse arg action, statusMsg1 '00'x statusMsg2
  2916.  
  2917.   action = translate( strip( action ) )
  2918.   statusMsg1 = strip( statusMsg1 )
  2919.   statusMsg2 = strip( statusMsg2 )
  2920.  
  2921.                         /* setup the variables for the status window  */
  2922.  
  2923.                         /* title for the status window                */
  2924.   StatusWindowTitle = prog.__Vname prog.__Version || ' - Working '
  2925.  
  2926.                     /* ignore dimension & position from the inifile   */
  2927.   window.__StatusWindowDim        = '550 150 10 10'
  2928.  
  2929.   i = 0
  2930.  
  2931.   i = i +1                      ; sw.__StatusMsgText1 = i
  2932.   RXTYPE.i  = 'TEXT'
  2933.   RXFLAGS.i = 'CENTER'
  2934.   RXLABEL.i = ' '
  2935.   RXINFO.i  = '1 1 31'
  2936.   RXVAL.i   = statusMsg1
  2937.   RXX.i     = 10
  2938.   RXY.i     = 80
  2939.  
  2940.   i = i +1                      ; sw.__StatusMsgText2 = i
  2941.   RXTYPE.i  = 'TEXT'
  2942.   RXFLAGS.i = 'CENTER'
  2943.   RXLABEL.i = ' '
  2944.   RXINFO.i  = '1 1 31'
  2945.   RXVAL.i   = statusMsg2
  2946.   RXX.i     = 10
  2947.   RXY.i     = 50
  2948.  
  2949.   i = i +1                      ; sw.__StaticStatusMsgText = i
  2950.   RXTYPE.i  = 'TEXT'
  2951.   RXFLAGS.i = 'CENTER'
  2952.   RXLABEL.i = '|'
  2953.   RXINFO.i  = '1 1 31'
  2954.   RXVAL.i   = 'Please wait.'
  2955.   RXX.i     = 20
  2956.   RXY.i     = 20
  2957.  
  2958.                                 /* number of groups in this dialog    */
  2959.   noOfGroupsInStatusWin = i
  2960.  
  2961.                         /* check if the status window is already open */
  2962.   RxQuery '"'statusWindowTitle'"'
  2963.   statusWindowOpen = rc         /* rc = 1 -> window already open      */
  2964.  
  2965.   if ( action = 'OPEN' | action = 'UPDATE' ) then
  2966.   do
  2967.     if rc = 0 then
  2968.     do
  2969.                         /* open the status window                     */
  2970.       RxDlg noOfGroupsInStatusWin  ,
  2971.             '"'statusWindowTitle'"' ,
  2972.             'WINDOW.__STATUSWINDOWDIM' ,
  2973.             'NOCLOSE|MODAL'
  2974.  
  2975.                         /* change the size of the text fields         */
  2976.                         /* (*?*) this is neccessary because the       */
  2977.                         /* initial size of the fields is limited to   */
  2978.                         /* 31                                         */
  2979.       RxSet '"'statusWindowTitle'"' sw.__StaticStatusMsgText  1 'SIZE' 475
  2980.       RxSet '"'statusWindowTitle'"' sw.__StatusMsgText1       1 'SIZE' 475
  2981.       RxSet '"'statusWindowTitle'"' sw.__StatusMsgText2       1 'SIZE' 475
  2982.  
  2983.  
  2984.       RxSet '"'statusWindowTitle'"' sw.__StaticStatusMsgText  1 'VAL' 'Please wait.'
  2985.     end /* if rc = 0 then */
  2986.  
  2987.                         /* update the text fields                     */
  2988.     if StatusMsg1 <> '=' then
  2989.       RxSet '"'statusWindowTitle'"' sw.__StatusMsgText1       1 'VAL' statusMsg1
  2990.  
  2991.     if StatusMsg2 <> '=' then
  2992.       RxSet '"'statusWindowTitle'"' sw.__StatusMsgText2       1 'VAL' statusMsg2
  2993.  
  2994.   end /* if ( action = 'OPEN' | ... */
  2995.  
  2996.   if action = 'CLOSE' & rc = 1 then
  2997.   do
  2998.                         /* close the status window                    */
  2999.     RxDlg '"'statusWindowTitle'"' 4
  3000.   end /* if action = 'CLOSE' & rc = 1 then */
  3001.  
  3002.                         /* clear the PM message queue                 */
  3003.   RxDlg '""' 255
  3004.  
  3005. RETURN
  3006.  
  3007. /* ------------------------------------------------------------------ */
  3008. /* ShowWarningMsg                                                     */
  3009. /*                                                                    */
  3010. /* Function: show a warning message box                               */
  3011. /*                                                                    */
  3012. /* Usage:    ShowWarningMsg {buttons,} warningMsg                     */
  3013. /*                                                                    */
  3014. /* where:    buttons - no. of the buttons to use (def. 0)             */
  3015. /*           warningMsg - warning message                             */
  3016. /*                                                                    */
  3017. /* returns:  the returncode of rxsay                                  */
  3018. /*                                                                    */
  3019. ShowWarningMsg: PROCEDURE expose (exposeList)
  3020.   parse arg buttons, warningMsg
  3021.  
  3022.   if datatype( buttons ) <> 'NUM' & buttons <> '' then
  3023.   do
  3024.     warningMsg = buttons || warningMsg
  3025.     buttons = 0
  3026.   end /* if datatype( ... */
  3027.   else
  3028.     if strip( buttons ) = '' then
  3029.       buttons = 0
  3030.  
  3031.   rxSay warningMsg || '!' '|' buttons+16  prog.__vName || ' - Warning'
  3032.  
  3033. RETURN rc
  3034.  
  3035. /* ------------------------------------------------------------------ */
  3036. /* ShowErrorMsg                                                       */
  3037. /*                                                                    */
  3038. /* Function: show a error message box                                 */
  3039. /*                                                                    */
  3040. /* Usage:    ShowErrorMsg {buttons,} errorMsg                         */
  3041. /*                                                                    */
  3042. /* where:    buttons - no. of the buttons to use (def. 0)             */
  3043. /*           errorMsg - error message                                 */
  3044. /*                                                                    */
  3045. /* returns:  the returncode of rxsay                                  */
  3046. /*                                                                    */
  3047. ShowErrorMsg: PROCEDURE expose (exposeList)
  3048.   parse arg buttons, errorMsg
  3049.  
  3050.   if datatype( buttons ) <> 'NUM' & buttons <> '' then
  3051.   do
  3052.     errorMsg = buttons || errorMsg
  3053.     buttons = 0
  3054.   end /* if datatype( ... */
  3055.   else
  3056.     if strip( buttons ) = '' then
  3057.       buttons = 0
  3058.  
  3059.   rxSay errorMsg || '!' '|' buttons+64  prog.__vName || ' - Error'
  3060.  
  3061. RETURN rc
  3062.  
  3063. /* ------------------------------------------------------------------ */
  3064. /* ShowMsg                                                            */
  3065. /*                                                                    */
  3066. /* Function: show a message box                                       */
  3067. /*                                                                    */
  3068. /* Usage:    ShowMsg {buttons,} Msg                                   */
  3069. /*                                                                    */
  3070. /* where:    buttons - no. of the buttons to use (def. 0)             */
  3071. /*           Msg - message                                            */
  3072. /*                                                                    */
  3073. /* returns:  the returncode of rxsay                                  */
  3074. /*                                                                    */
  3075. ShowMsg: PROCEDURE expose (exposeList)
  3076.   parse arg buttons, Msg
  3077.  
  3078.   if datatype( buttons ) <> 'NUM' & buttons <> '' then
  3079.   do
  3080.     Msg = buttons || Msg
  3081.     buttons = 0
  3082.   end /* if datatype( ... */
  3083.   else
  3084.     if strip( buttons ) = '' then
  3085.       buttons = 0
  3086.  
  3087.   rxSay Msg || '|' buttons+32  prog.__vName || ' - Message'
  3088. RETURN
  3089.  
  3090. /* ------------------------------------------------------------------ */
  3091. /* LoadRexxUtil                                                       */
  3092. /*                                                                    */
  3093. /* Function: load the DLL REXXUTIL                                    */
  3094. /*                                                                    */
  3095. /* Usage:    LoadREXXUtil                                             */
  3096. /*                                                                    */
  3097. /* where:    -                                                        */
  3098. /*                                                                    */
  3099. /* returns:  1 - okay                                                 */
  3100. /*           else error                                               */
  3101. /*                                                                    */
  3102. LoadREXXUtil:
  3103.                         /* install a temporary error handler          */
  3104.                         /* note: the previous errorhandler is auto-   */
  3105.                         /*       maticly restored a the end of the    */
  3106.                         /*       routine                              */
  3107.    SIGNAL ON SYNTAX NAME InitDllError
  3108.  
  3109.                         /* set a marker                               */
  3110.    dllInitOK = 0
  3111.  
  3112.                         /* first deregister the function              */
  3113.    call rxFuncDrop "SysLoadFuncs"
  3114.  
  3115.                         /* load the function                          */
  3116.    call rxFuncAdd "SysLoadFuncs", "REXXUTIL", "SysLoadFuncs"
  3117.  
  3118.                         /* call the init function                     */
  3119.    call SysLoadFuncs
  3120.  
  3121.    dllInitOK = 1        /* set the marker, this statement is not      */
  3122.                         /* executed if the previous statement fails!  */
  3123.  
  3124. InitDllError:
  3125.                         /* deRegister the name if the init call       */
  3126.                         /* failed                                     */
  3127.    if dllInitOK = 0 then
  3128.      call rxFuncDrop "SysLoadFuncs"
  3129.  
  3130.                         /* returns: 1 - dll init ok                   */
  3131.                         /*          0 - dll init error                */
  3132. RETURN dllInitOK
  3133.  
  3134. /* ------------------------------------------------------------------ */
  3135. /* function: test if a drive is ready                                 */
  3136. /*                                                                    */
  3137. /* call:     DriveReady( testDrive )                                  */
  3138. /*                                                                    */
  3139. /* where:    testdrive - Name of the drive to test (e.g. "A:")        */
  3140. /*                                                                    */
  3141. /* returns:  1 - drive is ready                                       */
  3142. /*           0 - drive is not ready                                   */
  3143. /*                                                                    */
  3144. DriveReady: PROCEDURE
  3145.   parse arg driveToTest ":" .
  3146.  
  3147.   thisRC = 0
  3148.  
  3149.                         /* install a temporary error handler to check */
  3150.                         /* if the drive is ready                      */
  3151.   SIGNAL ON NOTREADY Name DriveReadyEnd
  3152.  
  3153.   call stream driveToTest || ":\*", "D"
  3154.   thisRC = 1
  3155.  
  3156. DriveReadyEnd:
  3157.   RETURN thisRC
  3158.  
  3159. /* ------------------------------------------------------------------ */
  3160. /* InitRxDlg                                                          */
  3161. /*                                                                    */
  3162. /* Function: init Rexx Dialog variables                               */
  3163. /*                                                                    */
  3164. /* Usage:    InitRxDlg                                                */
  3165. /*                                                                    */
  3166. /* where:                                                             */
  3167. /*                                                                    */
  3168. /* returns:  nothing                                                  */
  3169. /*                                                                    */
  3170. InitRxDlg:
  3171.                     /* declare some REXX variables to avoid NOVALUE   */
  3172.                     /* condition if using the Rexx Dialog commands    */
  3173.   RXACTIVE = 'RXACTIVE'
  3174.   RXERR    = 'RXERR'
  3175.   RXDLG    = 'RXDLG'
  3176.   RXSAY    = 'RXSAY'
  3177.   RXQUERY  = 'RXQUERY'
  3178.   RXFILE   = 'RXFILE'
  3179.   RXSET    = 'RXSET'
  3180.  
  3181.   exposeList = exposeList ' RXACTIVE RXERR RXDLG RXSAY RXQUERY RXFILE RXSET '
  3182.  
  3183.   RXERR 'NUM|FULL'
  3184. RETURN
  3185.  
  3186. /* ------------------------------------------------------------------ */
  3187. /* InitVariables                                                      */
  3188. /*                                                                    */
  3189. /* Function: init the global variables                                */
  3190. /*                                                                    */
  3191. /* Usage:    InitVariables                                            */
  3192. /*                                                                    */
  3193. /* where:                                                             */
  3194. /*                                                                    */
  3195. /* returns:  nothing                                                  */
  3196. /*                                                                    */
  3197. InitVariables:
  3198.   exposeList = exposeList ,
  3199.                ' sourceFiles. targetFiles. copyrightFiles. compileCommands. '
  3200.  
  3201.                     /* name & path of the current ini file            */
  3202.   REXXCC2.__IniFileName = ''
  3203.  
  3204.                     /* name & path of the compiler                    */
  3205.   REXXCC2.__CompilerName = SearchProgram( 'REXXCC.CMD' )
  3206.   if CheckCompiler( REXXCC2.__CompilerName ) = 0 then
  3207.     REXXCC2.__CompilerName = ''
  3208.  
  3209.                     /* name of the editor                             */
  3210.   REXXCC2.__EditorName = 'E'
  3211.  
  3212.                     /* default target directory                       */
  3213.   REXXCC2.__DefaultTargetDir = ''
  3214.  
  3215.                     /* mode for REXXCC (1 - compress, 2 - compile)    */
  3216.   REXXCC.__Mode = 2
  3217.  
  3218.                     /* options for REXXCC                             */
  3219.                     /* 1 - add Code          2 - ignore Date          */
  3220.                     /* 3 - ignore version    4 - ignore extension     */
  3221.                     /* 5 - overwrite         6 - Use source           */
  3222.   REXXCC.__Options = '1'
  3223.  
  3224.                     /* linecount value for REXXCC                     */
  3225.   REXXCC.__LineCount = 0
  3226.  
  3227.                     /* options for REXXCC/2                           */
  3228.                     /* 1 : save options at program end                */
  3229.                     /* 2 : use environment variable REXXCC            */
  3230.                     /* 3 : edit compile command before executing      */
  3231.   REXXCC2.__Options = '2'
  3232.  
  3233.                     /* stem with the sourcefiles already selected     */
  3234.   SOURCEFILES.        = ' '
  3235.   SourceFiles.__CurPath = directory()
  3236.  
  3237.                     /* stem with the targetfiles already selected     */
  3238.   TARGETFILES.        = ' '
  3239.   TargetFiles.__CurPath = directory()
  3240.  
  3241.                     /* stem with the copyrightfiles already selected  */
  3242.   COPYRIGHTFILES.     = ' '
  3243.   CopyrightFiles.__CurPath = directory()
  3244.  
  3245.                     /* stem with the commands already executed        */
  3246.   CompileCommands. = ' '
  3247.  
  3248.                         /* default window dimensions & sizes          */
  3249.                         /* for the windows                            */
  3250.                         /* format: width height xpos ypos             */
  3251.   window.__MainWindowDim          = '650 300 100 50'
  3252.   window.__OptionWindowDim        = '625 375 10 10'
  3253.   window.__GetIniFileWindowDim    = '600 200 10 10'
  3254.   window.__EditCommandWindowDim   = '775 100 10 10'
  3255.   window.__CompileStatusWindowDim = '700 265 10 10'
  3256.   window.__StatusWindowDim        = '550 150 10 10'
  3257.  
  3258. RETURN
  3259.  
  3260. /* ------------------------------------------------------------------ */
  3261. /* error exit for NoValue errors                                      */
  3262. /*                                                                    */
  3263. NoValue:
  3264.   call ShowErrorMsg , 'NOVALUE error occured in line ' || sigl || '.' || crlf ||,
  3265.                       'The uninitialisized variable is "' || condition('D') || '"'
  3266.  
  3267. exit 255
  3268.  
  3269. /* ------------------------------------------------------------------ */
  3270.  
  3271.