home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / fixobj.zip / FIXOBJ.CMD next >
OS/2 REXX Batch file  |  1994-11-24  |  54KB  |  786 lines

  1. /*------------------------------------------------------------------------*\
  2. |                                                                          |
  3. |           FIXOBJ.CMD   - Version 1.0 - Version Date 1994-11-23           |
  4. |                 Copyright (C) 1994 by C F S Nevada, Inc.                 |
  5. |                                                                          |
  6. |                  by Dick Goran  - Voice    702-732-9616                  |
  7. |                                 - FAX      702-732-3847                  |
  8. |                                 - CIS      71154,2002                    |
  9. |                                 - FIDO     1:209/705                     |
  10. |                                 - IBMLink  DEV4672 at HONE81             |
  11. |                                 - Internet 71154.2002@compuserve.com     |
  12. |                                                                          |
  13. \*------------------------------------------------------------------------*/
  14. /*
  15.  
  16.    Generate a REXX program which can be used to build objects defined
  17.    in an .RC file by specifying the relevant object ID.
  18.  
  19.    Calling format:
  20.  
  21.       FIXOBJ  object_id  [ RC_file_name ]
  22.  
  23.    Output will be created in FIXOBJnn.CMD in the directory pointed
  24.    to by the TEMP environment variable. "nn" will will be the next
  25.    sequential number following any existing files created by this
  26.    program. The file name created will be shown on the console
  27.    at completion of this program.
  28.  
  29.    The generated program may be moved to any convenient location or
  30.    left in the \TEMP directory at the user's discretion.
  31.  
  32.    Prequisites:   OS/2 REXX with REXXUTIL
  33.  
  34. */
  35.  
  36.    SIGNAL ON ERROR                  /* trap object time errors     */
  37.    SIGNAL ON HALT                   /* trap object time errors     */
  38.    SIGNAL ON NOVALUE                /* trap object time errors     */
  39.    SIGNAL ON SYNTAX                 /* trap object time errors     */
  40.  
  41. GBL. = ''             /* initialize stem */                       /* 0041 */
  42. parse Version         GBL.REXX_version .                          /* 0042 */
  43. parse Source          GBL.operating_system,                       /* 0043 */
  44.                       GBL.calling_environment,                    /* 0044 */
  45.                       GBL.program_path_and_name                   /* 0045 */
  46. GBL.environment     = 'OS2ENVIRONMENT'                            /* 0046 */
  47. GBL.boot_drive      = LEFT( VALUE( 'COMSPEC',, GBL.environment ), 2 )
  48. GBL.program_name    = FILESPEC( 'N', GBL.program_path_and_name )  /* 0048 */
  49. GBL.program_path    = FILESPEC( 'D', GBL.program_path_and_name ) ||,
  50.                       FILESPEC( 'P', GBL.program_path_and_name )  /* 0050 */
  51.                       parse upper value GBL.program_name with fn '.' fe
  52. GBL.program_version = 1.0           /* version / mod of this program */
  53. GBL.error_count     = 0             /* input validation errors */ /* 0053 */
  54. GBL.object_count    = 0             /* number of objects created */
  55. call TIME 'E'                       /* set elapsed timer - sssss.uuuuu */
  56.                                                                   /* 0056 */
  57. say 'Begin' TRANSLATE( GBL.program_name ) 'at' TIME('N')          /* 0057 */
  58. if GBL.operating_system = 'OS/2' then                             /* 0058 */
  59.    do                                                             /* 0059 */
  60.       /*-------------------*\                                     /* 0060 */
  61.       |  Register REXXUTIL  |                                     /* 0061 */
  62.       \*-------------------*/                                     /* 0062 */
  63.       call REGISTER_REQUIRED_FUNCTIONS                            /* 0063 */
  64.    end                                                            /* 0064 */
  65.                                                                   /* 0065 */
  66. /*--------------------------------------------*\                  /* 0066 */
  67. |  Get Object ID value and optionally RC name  |                  /* 0067 */
  68. \*--------------------------------------------*/                  /* 0068 */
  69. parse ARG,                                                        /* 0069 */
  70.    specified_object_id,                                           /* 0070 */
  71.    specified_rc_name                                              /* 0071 */
  72. do while specified_object_id = ''                                 /* 0072 */
  73.    call GET_PARAMETERS_INTERACTIVELY                              /* 0073 */
  74. end                                                               /* 0074 */
  75.                                                                   /* 0075 */
  76. /*---------------------------------------*\                       /* 0076 */
  77. |  Assure format of predefined object ID  |                       /* 0077 */
  78. \*---------------------------------------*/                       /* 0078 */
  79. if LEFT( specified_object_id, 1 ) <> '<' then                     /* 0079 */
  80.    do                                                             /* 0080 */
  81.       specified_object_id = '<' ||,                               /* 0081 */
  82.                             specified_object_id                   /* 0082 */
  83.    end                                                            /* 0083 */
  84. if RIGHT( specified_object_id, 1 ) <> '>' then                    /* 0084 */
  85.    do                                                             /* 0085 */
  86.       specified_object_id = specified_object_id ||,               /* 0086 */
  87.                             '>'                                   /* 0087 */
  88.    end                                                            /* 0088 */
  89. GBL.object_id = TRANSLATE( specified_object_id ) /* always upper case */
  90.                                                                   /* 0090 */
  91. /*---------------------------------*\                             /* 0091 */
  92. |  Vailidate RC path and file name  |                             /* 0092 */
  93. \*---------------------------------*/                             /* 0093 */
  94. if specified_rc_name = '' then                                    /* 0094 */
  95.    do                                                             /* 0095 */
  96.       specified_rc_name = GBL.boot_drive ||,                      /* 0096 */
  97.                           '\OS2\INI.RC'                           /* 0097 */
  98.    end                                                            /* 0098 */
  99. if POS( '.', specified_rc_name ) = 0 then                         /* 0099 */
  100.    do                                                             /* 0100 */
  101.       /*-------------------------------*\                         /* 0101 */
  102.       |  Append default file extension  |                         /* 0102 */
  103.       \*-------------------------------*/                         /* 0103 */
  104.       specified_rc_name = specified_rc_name || '.RC'              /* 0104 */
  105.    end                                                            /* 0105 */
  106. GBL.rc_name = STREAM( specified_rc_name, 'C', 'QUERY EXISTS' )    /* 0106 */
  107. if GBL.rc_name = '' then                                          /* 0107 */
  108.    do                                                             /* 0108 */
  109.       GBL.error_count = GBL.error_count + 1                       /* 0109 */
  110.       say COPIES( ' ', 3 )               ||,                      /* 0110 */
  111.           specified_rc_name              ||,                      /* 0111 */
  112.           ' is not a valid file name'                             /* 0112 */
  113.    end                                                            /* 0113 */
  114.                                                                   /* 0114 */
  115. /*------------------------------------------------*\              /* 0115 */
  116. |  Validate presence of TEMP environment variable  |              /* 0116 */
  117. |  and get next available sequential extension     |              /* 0117 */
  118. \*------------------------------------------------*/              /* 0118 */
  119. temp_directory = VALUE( 'TEMP',, GBL.environment )                /* 0119 */
  120. if temp_directory = '' then                                       /* 0120 */
  121.    do                                                             /* 0121 */
  122.       GBL.error_count = GBL.error_count + 1                       /* 0122 */
  123.       say '   TEMP environment variable must point to a valid directory' ||,
  124.           ' for output file'                                      /* 0124 */
  125.    end                                                            /* 0125 */
  126. else                                                              /* 0126 */
  127.    do                                                             /* 0127 */
  128.       /*-------------------------------------*\                   /* 0128 */
  129.       |  Find next available sequence number  |                   /* 0129 */
  130.       \*-------------------------------------*/                   /* 0130 */
  131.       temp_arg = temp_directory || '\' || fn || '*.*'             /* 0131 */
  132.       call SysFileTree temp_arg, 'temp_stem', 'F'                 /* 0132 */
  133.       next_sequence_number = 0                                    /* 0133 */
  134.       if temp_stem.0 > 0 then                                     /* 0134 */
  135.          do ts = 1 to temp_stem.0                                 /* 0135 */
  136.             parse value temp_stem.ts with,                        /* 0136 */
  137.                file_date,                                         /* 0137 */
  138.                file_time,                                         /* 0138 */
  139.                file_size,                                         /* 0139 */
  140.                file_attr,                                         /* 0140 */
  141.                file_path_and_name                                 /* 0141 */
  142.             file_path_and_name = STRIP( file_path_and_name )      /* 0142 */
  143.             parse value FILESPEC( 'N', file_path_and_name ) with, /* 0143 */
  144.                file_name '.' file_ext                             /* 0144 */
  145.             sequence_number = RIGHT( file_name, 2 )               /* 0145 */
  146.             if DATATYPE( sequence_number ) = 'NUM' then           /* 0146 */
  147.                do                                                 /* 0147 */
  148.                   next_sequence_number = sequence_number + 1      /* 0148 */
  149.                end                                                /* 0149 */
  150.          end                                                      /* 0150 */
  151.    end                                                            /* 0151 */
  152. GBL.output_file   = temp_directory                                        ||,
  153.                     '\' || fn || RIGHT( next_sequence_number, 2, '0' )    ||,
  154.                     '.CMD'                                        /* 0154 */
  155. GBL.program_title = FILESPEC( 'N', GBL.output_file )                      ||,
  156.                     ' - Program to recreate '                             ||,
  157.                     GBL.object_id                                         ||,
  158.                     ' related objects'                            /* 0158 */
  159.                                                                   /* 0159 */
  160. /*----------------------------*\                                  /* 0160 */
  161. |  Check for any prior errors  |                                  /* 0161 */
  162. \*----------------------------*/                                  /* 0162 */
  163. if GBL.error_count > 0 then                                       /* 0163 */
  164.    do                                                             /* 0164 */
  165.       say '   Program cancelled because of above errors'          /* 0165 */
  166.       call EOJ                                                    /* 0166 */
  167.    end                                                            /* 0167 */
  168.                                                                   /* 0168 */
  169. /*------------------------------------------*\                    /* 0169 */
  170. |  Strings for building object REXX program  |                    /* 0170 */
  171. \*------------------------------------------*/                    /* 0171 */
  172. GBL.width      = 76                 /* maximum program line width */
  173. GBL.tl         = '/*-'              /* top left */                /* 0173 */
  174. GBL.tr         = '-*\'              /* top right */               /* 0174 */
  175. GBL.bl         = '\*-'              /* bottom left */             /* 0175 */
  176. GBL.br         = '-*/'              /* bottom right */            /* 0176 */
  177. GBL.horizontal = '-'                /* horizontal fill character */
  178. GBL.left_vert  = '|  '              /* vertical fill character */ /* 0178 */
  179. GBL.right_vert = '  |'              /* vertical fill character */ /* 0179 */
  180.                                                                   /* 0180 */
  181. i= 0                                                              /* 0181 */
  182. i=i+1; GBL.program_init.i =,                                      /* 0182 */
  183.          GBL.tl                                                           ||,
  184.          COPIES( GBL.horizontal, GBL.width - 6 )                          ||,
  185.          GBL.tr                                                   /* 0185 */
  186. i=i+1; GBL.program_init.i =,                                      /* 0186 */
  187.          GBL.left_vert                                                    ||,
  188.          COPIES( ' ', GBL.width - 6 )                                     ||,
  189.          GBL.right_vert                                           /* 0189 */
  190. i=i+1; GBL.program_init.i =,                                      /* 0190 */
  191.          GBL.left_vert                                                    ||,
  192.          CENTER( GBL.program_title, GBL.width - 6 )                       ||,
  193.          GBL.right_vert                                           /* 0193 */
  194. i=i+1; GBL.program_init.i =,                                      /* 0194 */
  195.          GBL.left_vert                                                    ||,
  196.          COPIES( ' ', GBL.width - 6 )                                     ||,
  197.          GBL.right_vert                                           /* 0197 */
  198. i=i+1; GBL.program_init.i =,                                      /* 0198 */
  199.          GBL.left_vert                                                    ||,
  200.          CENTER( 'Created by FIXOBJ - Copyright 1994 by C F S Nevada, Inc.',,
  201.                  GBL.width - 6 )                                          ||,
  202.          GBL.right_vert                                           /* 0202 */
  203. i=i+1; GBL.program_init.i =,                                      /* 0203 */
  204.          GBL.left_vert                                                    ||,
  205.          CENTER( 'Written by Dick Goran - 71154.2002@compuserve.com',,
  206.                  GBL.width - 6 )                                          ||,
  207.          GBL.right_vert                                           /* 0207 */
  208. i=i+1; GBL.program_init.i =,                                      /* 0208 */
  209.          GBL.left_vert                                                    ||,
  210.          COPIES( ' ', GBL.width - 6 )                                     ||,
  211.          GBL.right_vert                                           /* 0211 */
  212. i=i+1; GBL.program_init.i =,                                      /* 0212 */
  213.          GBL.bl                                                           ||,
  214.          COPIES( GBL.horizontal, GBL.width - 6 )                          ||,
  215.          GBL.br                                                   /* 0215 */
  216. i=i+1; GBL.program_init.i = '/*'                                  /* 0216 */
  217. i=i+1; GBL.program_init.i = ' '                                   /* 0217 */
  218. i=i+1; GBL.program_init.i =,                                      /* 0218 */
  219.          COPIES( ' ', 3 )                                                 ||,
  220.          'This program will recreate all of the standard system'          ||,
  221.          ' objects related'                                       /* 0221 */
  222. i=i+1; GBL.program_init.i =,                                      /* 0222 */
  223.          COPIES( ' ', 3 )                                                 ||,
  224.          'to '                                                            ||,
  225.          GBL.object_id                                                    ||,
  226.          ' from the information in '                                      ||,
  227.          GBL.rc_name                                                      ||,
  228.          '.'                                                      /* 0228 */
  229. i=i+1; GBL.program_init.i = ' '                                   /* 0229 */
  230. i=i+1; GBL.program_init.i = '*/'                                  /* 0230 */
  231. i=i+1; GBL.program_init.i = ' '                                   /* 0231 */
  232. i=i+1; GBL.program_init.i =,                                      /* 0232 */
  233.          'call RxFuncAdd "SysLoadFuncs", "REXXUTIL", "SysLoadFuncs"'
  234. i=i+1; GBL.program_init.i =,                                      /* 0234 */
  235.          'call SysLoadFuncs'                                      /* 0235 */
  236. i=i+1; GBL.program_init.i =,                                      /* 0236 */
  237.          'say "Begin' FILESPEC( 'N', GBL.output_file ) 'at" TIME("N")'
  238. i=i+1; GBL.program_init.i = ' '                                   /* 0238 */
  239.        GBL.program_init.0 = i                                     /* 0239 */
  240.                                                                   /* 0240 */
  241. i= 0                                                              /* 0241 */
  242. i=i+1; GBL.program_body.i =,                                      /* 0242 */
  243.          'call SysCreateObject class, title, location, setup_string, "F"'
  244. i=i+1; GBL.program_body.i =,                                      /* 0244 */
  245.          'if RESULT <> 1 then'                                    /* 0245 */
  246. i=i+1; GBL.program_body.i =,                                      /* 0246 */
  247.          '   do'                                                  /* 0247 */
  248. i=i+1; GBL.program_body.i =,                                      /* 0248 */
  249.          '      say "   Unable to create" title'                  /* 0249 */
  250. i=i+1; GBL.program_body.i =,                                      /* 0250 */
  251.          '      if class = "WPFolder" then SIGNAL END_OF_JOB'     /* 0251 */
  252. i=i+1; GBL.program_body.i =,                                      /* 0252 */
  253.          '   end'                                                 /* 0253 */
  254. i=i+1; GBL.program_body.i =,                                      /* 0254 */
  255.          'else'                                                   /* 0255 */
  256. i=i+1; GBL.program_body.i =,                                      /* 0256 */
  257.          '   do'                                                  /* 0257 */
  258. i=i+1; GBL.program_body.i =,                                      /* 0258 */
  259.          '      say "  " title "created in/on" location'          /* 0259 */
  260. i=i+1; GBL.program_body.i =,                                      /* 0260 */
  261.          '   end'                                                 /* 0261 */
  262. i=i+1; GBL.program_body.i = ' '                                   /* 0262 */
  263.        GBL.program_body.0 = i                                     /* 0263 */
  264.                                                                   /* 0264 */
  265. /*----------------------------------------------------------*\    /* 0265 */
  266. |  Process each line in .RC file which references object ID  |    /* 0266 */
  267. \*----------------------------------------------------------*/    /* 0267 */
  268. do while LINES( GBL.rc_name ) > 0                                 /* 0268 */
  269.                                                                   /* 0269 */
  270.    input_line = LINEIN( GBL.rc_name )                             /* 0270 */
  271.    if POS( GBL.object_id, input_line ) = 0 then iterate /* ignore if unrelated */
  272.                                                                   /* 0272 */
  273.    /*----------------------*\                                     /* 0273 */
  274.    |  Isolate setup string  |                                     /* 0274 */
  275.    \*----------------------*/                                     /* 0275 */
  276.    setup_string_beg_ptr = LASTPOS( '"', input_line, LENGTH( input_line ) - 1 )
  277.    if setup_string_beg_ptr = 0 then                               /* 0277 */
  278.       do                                                          /* 0278 */
  279.          say '   Unable to locate setup string for:'              /* 0279 */
  280.          say '   ' ||,                                            /* 0280 */
  281.              input_line                                           /* 0281 */
  282.          iterate                                                  /* 0282 */
  283.       end                                                         /* 0283 */
  284.    setup_string_beg_ptr = setup_string_beg_ptr + 1                /* 0284 */
  285.                                                                   /* 0285 */
  286.    /*------------------------------------------------------*\     /* 0286 */
  287.    |  Isolate class, title, location and optionally option  |     /* 0287 */
  288.    \*------------------------------------------------------*/     /* 0288 */
  289.    parse value input_line with,                                   /* 0289 */
  290.       title_class_location_option   =(setup_string_beg_ptr),      /* 0290 */
  291.       setup_string   '"'                                          /* 0291 */
  292.    parse value title_class_location_option with,                  /* 0292 */
  293.       .                 '"PM_InstallObject"',                     /* 0293 */
  294.       .                 '"',                                      /* 0294 */
  295.       title             ';',                                      /* 0295 */
  296.       class             ';',                                      /* 0296 */
  297.       location_option   '"',                                      /* 0297 */
  298.       .                                                           /* 0298 */
  299.    if POS( ';', location_option ) > 0 then                        /* 0299 */
  300.       do                                                          /* 0300 */
  301.          parse value location_option with,                        /* 0301 */
  302.             location  ';',                                        /* 0302 */
  303.             option                                                /* 0303 */
  304.       end                                                         /* 0304 */
  305.    else                                                           /* 0305 */
  306.       do                                                          /* 0306 */
  307.          location = location_option                               /* 0307 */
  308.          option = ''                                              /* 0308 */
  309.       end                                                         /* 0309 */
  310.                                                                   /* 0310 */
  311.    /*------------------------------*\                             /* 0311 */
  312.    |  Program initialization lines  |                             /* 0312 */
  313.    \*------------------------------*/                             /* 0313 */
  314.    if GBL.object_count = 0 then                                   /* 0314 */
  315.       do i = 1 to GBL.program_init.0                              /* 0315 */
  316.          call LINEOUT GBL.output_file, GBL.program_init.i         /* 0316 */
  317.       end                                                         /* 0317 */
  318.    GBL.object_count = GBL.object_count + 1                        /* 0318 */
  319.                                                                   /* 0319 */
  320.    /*-------------------------------*\                            /* 0320 */
  321.    |  Program lines to build object  |                            /* 0321 */
  322.    \*-------------------------------*/                            /* 0322 */
  323.    output_line = GBL.tl                                                   ||,
  324.                  COPIES( GBL.horizontal, LENGTH( title ) )                ||,
  325.                  GBL.tr                                           /* 0325 */
  326.    call LINEOUT GBL.output_file, output_line                      /* 0326 */
  327.    output_line = GBL.left_vert                                            ||,
  328.                  title                                                    ||,
  329.                  GBL.right_vert                                   /* 0329 */
  330.    call LINEOUT GBL.output_file, output_line                      /* 0330 */
  331.    output_line = GBL.bl                                                   ||,
  332.                  COPIES( GBL.horizontal, LENGTH( title ) )                ||,
  333.                  GBL.br                                           /* 0333 */
  334.    call LINEOUT GBL.output_file, output_line                      /* 0334 */
  335.                                                                   /* 0335 */
  336.    output_line = LEFT( 'title', 12 )                                      ||,
  337.                  ' = "' || title || '"'                           /* 0337 */
  338.    call LINEOUT GBL.output_file, output_line                      /* 0338 */
  339.    output_line = LEFT( 'class', 12 )                                      ||,
  340.                  ' = "' || class || '"'                           /* 0340 */
  341.    call LINEOUT GBL.output_file, output_line                      /* 0341 */
  342.    output_line = LEFT( 'location', 12 )                                   ||,
  343.                  ' = "' || location || '"'                        /* 0343 */
  344.    call LINEOUT GBL.output_file, output_line                      /* 0344 */
  345.    output_line = LEFT( 'setup_string', 12 )                               ||,
  346.                  ' =,'                                            /* 0346 */
  347.    call LINEOUT GBL.output_file, output_line                      /* 0347 */
  348.    do while setup_string <> ''                                    /* 0348 */
  349.       parse value setup_string with,                              /* 0349 */
  350.          token ';' setup_string                                   /* 0350 */
  351.       output_line = COPIES( ' ', 6 )                                      ||,
  352.                     '"' || token || ';"'                          /* 0352 */
  353.       if LENGTH( output_line ) < ( GBL.width - 3 )then            /* 0353 */
  354.          do                                                       /* 0354 */
  355.             output_line = LEFT( output_line, GBL.width - 3 )              ||,
  356.                           '||,'                                   /* 0356 */
  357.          end                                                      /* 0357 */
  358.       else                                                        /* 0358 */
  359.          do                                                       /* 0359 */
  360.             output_line = output_line || ' ||,'                   /* 0360 */
  361.          end                                                      /* 0361 */
  362.       call LINEOUT GBL.output_file, output_line                   /* 0362 */
  363.    end                                                            /* 0363 */
  364.    output_line = COPIES( ' ', 6 )                                         ||,
  365.                  '""'                                             /* 0365 */
  366.    call LINEOUT GBL.output_file, output_line                      /* 0366 */
  367.                                                                   /* 0367 */
  368.    do i = 1 to GBL.program_body.0                                 /* 0368 */
  369.       call LINEOUT GBL.output_file, GBL.program_body.i            /* 0369 */
  370.    end                                                            /* 0370 */
  371.                                                                   /* 0371 */
  372. end                                                               /* 0372 */
  373. call LINEOUT GBL.output_file, 'END_OF_JOB:'                       /* 0373 */
  374. output_line =,                                                    /* 0374 */
  375.    'say "End  ' FILESPEC( 'N', GBL.output_file ) 'at" TIME("N")'  /* 0375 */
  376. call LINEOUT GBL.output_file, output_line                         /* 0376 */
  377. call LINEOUT GBL.output_file, 'exit'                              /* 0377 */
  378.                                                                   /* 0378 */
  379. if GBL.object_count > 0 then                                      /* 0379 */
  380.    do                                                             /* 0380 */
  381.       call STREAM GBL.output_file, 'C', 'CLOSE'                   /* 0381 */
  382.       say '  ' GBL.output_file 'has been created'                 /* 0382 */
  383.    end                                                            /* 0383 */
  384. else                                                              /* 0384 */
  385.    do                                                             /* 0385 */
  386.       say '   Unable to find any objects matching '                       ||,
  387.           GBL.object_id                                           /* 0387 */
  388.    end                                                            /* 0388 */
  389.                                                                   /* 0389 */
  390. call EOJ 0                                                        /* 0390 */
  391.                                                                   /* 0391 */
  392.                                                                   /* 0392 */
  393. /*------------------------------------------------------------------------*\
  394. |                                                                          |
  395. |                  Request paramters be entered manually                   |
  396. |                                                                          |
  397. \*------------------------------------------------------------------------*/
  398. GET_PARAMETERS_INTERACTIVELY:                                     /* 0398 */
  399. say '   Enter object ID of object to be rebuilt'                  /* 0399 */
  400. parse pull specified_object_id                                    /* 0400 */
  401. say '   Enter option .RC file path and name or <Enter> if INI.RC' /* 0401 */
  402. pull specified_rc_name                                            /* 0402 */
  403. return                                                            /* 0403 */
  404.                                                                   /* 0404 */
  405.                                                                   /* 0405 */
  406. !tr! = VALUE('TRACE',,GBL.environment); if !tr! <> '' then do; TRACE(!tr!); nop; end
  407. /*------------------------------------------------------------------------*\
  408. |                                                                          |
  409. |                                End of Job                                |
  410. |                                                                          |
  411. \*------------------------------------------------------------------------*/
  412. EOJ:                                                              /* 0412 */
  413.    Procedure expose,                                              /* 0413 */
  414.       GBL.                                                        /* 0414 */
  415.                                                                   /* 0415 */
  416. if ARG() = 0 then                                                 /* 0416 */
  417.    eoj_rc = 0                                                     /* 0417 */
  418. else                                                              /* 0418 */
  419.    eoj_rc = ARG(1)                                                /* 0419 */
  420.                                                                   /* 0420 */
  421. elapsed_time = TIME('E')            /* get elapsed time - sssss.uuuuu */
  422. parse value elapsed_time with seconds '.' micro_seconds           /* 0422 */
  423. if LEFT( micro_seconds, 1, 1 ) >= 5 then                          /* 0423 */
  424.    seconds = seconds + 1                                          /* 0424 */
  425. ss = FORMAT( seconds // 60, 2 )                                   /* 0425 */
  426. minutes = ( seconds - ss ) / 60                                   /* 0426 */
  427. mm = FORMAT( minutes // 60, 2 )                                   /* 0427 */
  428. hh = FORMAT( ( minutes - mm ) / 60, 2 )                           /* 0428 */
  429. duration = hh':'mm':'ss                                           /* 0429 */
  430.                                                                   /* 0430 */
  431. program_name = TRANSLATE( FILESPEC( 'N', GBL.program_path_and_name ) )
  432. say 'EOJ  ' program_name 'at' TIME('N') ||,                       /* 0432 */
  433.     ', duration' TRANSLATE( duration, '0', ' ' )                  /* 0433 */
  434. exit eoj_rc                                                       /* 0434 */
  435.                                                                   /* 0435 */
  436. /*------------------------------------------------------------------------*\
  437. |                                                                          |
  438. |                   Register external function routines                    |
  439. |                                                                          |
  440. \*------------------------------------------------------------------------*/
  441. REGISTER_REQUIRED_FUNCTIONS:                                      /* 0441 */
  442.    Procedure expose GBL.REXX_version                              /* 0442 */
  443.                                                                   /* 0443 */
  444. /*----------------------------------------*\                      /* 0444 */
  445. |  Load REXXUtil External Function Module  |                      /* 0445 */
  446. \*----------------------------------------*/                      /* 0446 */
  447. module             = 'REXXUTIL'                                   /* 0447 */
  448. entry_name         = 'SysLoadFuncs'                               /* 0448 */
  449. function_name      = 'SysLoadFuncs'                               /* 0449 */
  450. anticipated_return = ''                                           /* 0450 */
  451. call REGISTER_ROUTINE function_name module entry_name anticipated_return
  452. return                                                            /* 0452 */
  453.                                                                   /* 0453 */
  454.                                                                   /* 0454 */
  455. /*---------------------*\                                         /* 0455 */
  456. |  Register Subroutine  |                                         /* 0456 */
  457. \*---------------------*/                                         /* 0457 */
  458. REGISTER_ROUTINE:                                                 /* 0458 */
  459.    Procedure                                                      /* 0459 */
  460.                                                                   /* 0460 */
  461. parse ARG  function_name,                                         /* 0461 */
  462.            module,                                                /* 0462 */
  463.            entry_name,                                            /* 0463 */
  464.            anticipated_return                                     /* 0464 */
  465.                                                                   /* 0465 */
  466. if RxFuncQuery(function_name) = 0 then return      /* function registered */
  467.                                                                   /* 0467 */
  468. if LENGTH(module) > 8 then                                        /* 0468 */
  469.    do                                                             /* 0469 */
  470.       dll_drive = FILESPEC( 'D', module )                         /* 0470 */
  471.       dll_path  = STRIP( FILESPEC( 'P', module ), 'T', '\' )      /* 0471 */
  472.       module    = FILESPEC( 'N', module )                         /* 0472 */
  473.       '@' || dll_drive                                            /* 0473 */
  474.       '@cd' dll_drive || dll_path                                 /* 0474 */
  475.    end                                                            /* 0475 */
  476. else                                                              /* 0476 */
  477.    do                                                             /* 0477 */
  478.       dll_drive = ''                                              /* 0478 */
  479.    end                                                            /* 0479 */
  480.                                                                   /* 0480 */
  481. parse var module module_fname '.' module_fext                     /* 0481 */
  482. if RxFuncAdd( function_name, module_fname, entry_name ) = 0 then  /* 0482 */
  483.    do                                                             /* 0483 */
  484.       register_call = 'call' function_name                        /* 0484 */
  485.       interpret register_call                                     /* 0485 */
  486.       if WORD( RESULT, 1 ) <> WORD( anticipated_return, 1 ) then  /* 0486 */
  487.          do                                                       /* 0487 */
  488.             Say function_name 'returned' RESULT '-',              /* 0488 */
  489.                                          anticipated_return 'was expected'
  490.             exit 255                                              /* 0490 */
  491.          end                                                      /* 0491 */
  492.    end                                                            /* 0492 */
  493. else                                                              /* 0493 */
  494.    do                                                             /* 0494 */
  495.       Say 'RxFuncAdd returned' RESULT 'registering' module        /* 0495 */
  496.       exit 254                                                    /* 0496 */
  497.    end                                                            /* 0497 */
  498. if dll_drive <> '' then                                           /* 0498 */
  499.    do                                                             /* 0499 */
  500.       Parse Source . . GBL.program_path_and_name                  /* 0500 */
  501.       '@' || LEFT( GBL.program_path_and_name, 2 )                 /* 0501 */
  502.    end                                                            /* 0502 */
  503. return                                                            /* 0503 */
  504.                                                                   /* 0504 */
  505. /*------------------------------------------------------------------------*\
  506. |                                                                          |
  507. |                              Trap Routines                               |
  508. |                                                                          |
  509. \*------------------------------------------------------------------------*/
  510. ERROR:   call TRAP_PROCESSING SIGL, 'ERROR',   RC                 /* 0510 */
  511. FAILURE: call TRAP_PROCESSING SIGL, 'FAILURE', RC                 /* 0511 */
  512. HALT:    call TRAP_PROCESSING SIGL, 'HALT',    ''                 /* 0512 */
  513. NOVALUE: call TRAP_PROCESSING SIGL, 'NOVALUE', ''                 /* 0513 */
  514. SYNTAX:  call TRAP_PROCESSING SIGL, 'SYNTAX',  RC                 /* 0514 */
  515.                                                                   /* 0515 */
  516. /* Rev. 94/06/14 */                                               /* 0516 */
  517. TRAP_PROCESSING:                                                  /* 0517 */
  518.    parse Source . . TRAP.path_and_program                         /* 0518 */
  519.    if POS( ':', TRAP.path_and_program ) > 0 then                  /* 0519 */
  520.       /* get source line if it is available */                    /* 0520 */
  521.       do                                                          /* 0521 */
  522.          trap_source_line = STRIP( SOURCELINE(ARG(1)) )           /* 0522 */
  523.       end                                                         /* 0523 */
  524.    else                                                           /* 0524 */
  525.       /* program is running in macrospace */                      /* 0525 */
  526.       do                                                          /* 0526 */
  527.          TRAP.path_and_program = VALUE( 'TEMP',, 'OS2ENVIRONMENT' ) ||,
  528.                                  TRAP.path_and_program            /* 0528 */
  529.          trap_source_line = 'Source line is not available.'       /* 0529 */
  530.       end                                                         /* 0530 */
  531.                                                                   /* 0531 */
  532.    parse value FILESPEC( 'N', TRAP.path_and_program ) with,       /* 0532 */
  533.       TRAP.fn '.' TRAP.fe                                         /* 0533 */
  534.    trap_file_name = FILESPEC( 'D', TRAP.path_and_program ) ||,    /* 0534 */
  535.                     FILESPEC( 'P', TRAP.path_and_program ) ||,    /* 0535 */
  536.                     TRAP.fn || '.' || 'DMP'                       /* 0536 */
  537.                                                                   /* 0537 */
  538.    /*------------------------------------------*\                 /* 0538 */
  539.    |  check for reason not to create .DMP file  |                 /* 0539 */
  540.    \*------------------------------------------*/                 /* 0540 */
  541.    if ARG(2) = 'HALT' then                                        /* 0541 */
  542.       do                                                          /* 0542 */
  543.          trap_file_name = ''                                      /* 0543 */
  544.       end                                                         /* 0544 */
  545.    if RxFuncQuery( 'VARDUMP' ) <> 0 then                          /* 0545 */
  546.       do                                                          /* 0546 */
  547.          trap_file_name = ''                                      /* 0547 */
  548.       end                                                         /* 0548 */
  549.    if POS( ':', trap_file_name ) = 0 then                         /* 0549 */
  550.       do                                                          /* 0550 */
  551.          trap_file_name = ''                                      /* 0551 */
  552.       end                                                         /* 0552 */
  553.                                                                   /* 0553 */
  554.    /*------------------------*\                                   /* 0554 */
  555.    |  Build trap message box  |                                   /* 0555 */
  556.    \*------------------------*/                                   /* 0556 */
  557.    dbl.h    = 'CD'x                 /* ═ double line - horizontal   */
  558.    dbl.v    = 'BA'x                 /* ║ double line - vertical     */
  559.    dbl.bl   = 'C8'x                 /* ╚ double line - bottom left  */
  560.    dbl.br   = 'BC'x                 /* ╝ double line - bottom right */
  561.    dbl.tl   = 'C9'x                 /* ╔ double line - top left     */
  562.    dbl.tr   = 'BB'x                 /* ╗ double line - top right    */
  563.    say ' '                                                        /* 0563 */
  564.    trap_error_description =,                                      /* 0564 */
  565.       'Error line = ' || ARG(1) ||,                               /* 0565 */
  566.       '; ' ||,                                                    /* 0566 */
  567.       ARG(2) ||,                                                  /* 0567 */
  568.       ' error.'                                                   /* 0568 */
  569.    if ARG(3) <> '' then                                           /* 0569 */
  570.       trap_error_description = trap_error_description ||,         /* 0570 */
  571.                                '  Return code = ' || ARG(3)       /* 0571 */
  572.    say dbl.tl || COPIES( dbl.h, LENGTH(trap_error_description) + 2 ) || dbl.tr
  573.    say dbl.v  || COPIES( ' ',   LENGTH(trap_error_description) + 2 ) || dbl.v
  574.    say dbl.v CENTER( TRAP.fn || '.CMD', LENGTH(trap_error_description)) dbl.v
  575.    say dbl.v               trap_error_description                       dbl.v
  576.    if trap_file_name <> '' then                                   /* 0576 */
  577.       do                                                          /* 0577 */
  578.    say dbl.v  || COPIES( ' ',   LENGTH(trap_error_description) + 2 ) || dbl.v
  579.    say dbl.v     CENTER( 'See: ' || trap_file_name,,              /* 0579 */
  580.                                       LENGTH(trap_error_description) )  dbl.v
  581.       end                                                         /* 0581 */
  582.    say dbl.v  || COPIES( ' ',   LENGTH(trap_error_description) + 2 ) || dbl.v
  583.    say dbl.bl || COPIES( dbl.h, LENGTH(trap_error_description) + 2 ) || dbl.br
  584.    say ' '                                                        /* 0584 */
  585.    say 'Source line at time of trap:'                             /* 0585 */
  586.    say '   ' || trap_source_line                                  /* 0586 */
  587.    say ' '                                                        /* 0587 */
  588.                                                                   /* 0588 */
  589.    /*---------------------------------*\                          /* 0589 */
  590.    |  Create .DMP file if appropriate  |                          /* 0590 */
  591.    \*---------------------------------*/                          /* 0591 */
  592.    if trap_file_name <> '' then                                   /* 0592 */
  593.       do                                                          /* 0593 */
  594.          call SysFileDelete trap_file_name                        /* 0594 */
  595.          /* remove meaningless labels from dump for clarity */    /* 0595 */
  596.          drop dbl. TRAP. RC RESULT SIGL !tr!                      /* 0596 */
  597.          call VARDUMP trap_file_name  /* write variables to program.DMP file */
  598.       end                                                         /* 0598 */
  599.    exit 254                                                       /* 0599 */
  600. /*---------  REXX Cross Reference  - Created: 11/24/94 3:36pm ----------*\
  601.  
  602. ---- VARIABLES ----
  603. !tr!                0406<  0406   0406   0596
  604. GBL.                0041<  0414
  605. GBL.REXX_version    0042   0442
  606. GBL.bl              0175<  0213   0331
  607. GBL.boot_drive      0047<  0096
  608. GBL.br              0176<  0215   0333
  609. GBL.calling_environment
  610.                     0044
  611. GBL.environment     0046<  0047   0119   0406
  612. GBL.error_count     0053<  0109<  0109   0122<  0122   0163
  613. GBL.horizontal      0177<  0184   0214   0324   0332
  614. GBL.left_vert       0178<  0187   0191   0195   0199   0204   0209   0327
  615. GBL.object_count    0054<  0314   0318<  0318   0379
  616. GBL.object_id       0089<  0157   0225   0271   0387
  617. GBL.operating_system
  618.                     0043   0058
  619. GBL.output_file     0152<  0155   0237   0316   0326   0330   0334   0338
  620.                     0341   0344   0347   0362   0366   0369   0373   0375
  621.                     0376   0377   0381   0382
  622. GBL.program_body.0  0263<  0368
  623. GBL.program_body.i  0242<  0244<  0246<  0248<  0250<  0252<  0254<  0256<
  624.                     0258<  0260<  0262<  0369
  625. GBL.program_init.0  0239<  0315
  626. GBL.program_init.i  0182<  0186<  0190<  0194<  0198<  0203<  0208<  0212<
  627.                     0216<  0217<  0218<  0222<  0229<  0230<  0231<  0232<
  628.                     0234<  0236<  0238<  0316
  629. GBL.program_name    0048<  0051   0057
  630. GBL.program_path    0049<
  631. GBL.program_path_and_name
  632.                     0045   0048   0049   0050   0431   0500   0501
  633. GBL.program_title   0155<  0192
  634. GBL.program_version
  635.                     0052<
  636. GBL.rc_name         0106<  0107   0227   0268   0270
  637. GBL.right_vert      0179<  0189   0193   0197   0202   0207   0211   0329
  638. GBL.tl              0173<  0183   0323
  639. GBL.tr              0174<  0185   0325
  640. GBL.width           0172<  0184   0188   0192   0196   0201   0206   0210
  641.                     0214   0353   0355
  642. RC                  0510   0511   0514   0596
  643. RESULT              0486   0488   0495   0596
  644. SIGL                0510   0511   0512   0513   0514   0596
  645. TRAP.               0596
  646. TRAP.fe             0533
  647. TRAP.fn             0533   0536   0574
  648. TRAP.path_and_program
  649.                     0518   0519   0527<  0528   0532   0534   0535
  650. Version             0042
  651. anticipated_return  0450<  0451   0464   0486   0489
  652. class               0296   0340
  653. dbl.                0596
  654. dbl.bl              0559<  0583
  655. dbl.br              0560<  0583
  656. dbl.h               0557<  0572   0583
  657. dbl.tl              0561<  0572
  658. dbl.tr              0562<  0572
  659. dbl.v               0558<  0573   0573   0574   0574   0575   0575   0578
  660.                     0578   0579   0580   0582   0582
  661. dll_drive           0470<  0473   0474   0478<  0498
  662. dll_path            0471<  0474
  663. duration            0429<  0433
  664. elapsed_time        0421<  0422
  665. entry_name          0448<  0451   0463   0482
  666. eoj_rc              0417<  0419<  0434
  667. fe                  0051
  668. file_attr           0140
  669. file_date           0137
  670. file_ext            0144
  671. file_name           0144   0145
  672. file_path_and_name  0141   0142<  0142   0143
  673. file_size           0139
  674. file_time           0138
  675. fn                  0051   0131   0153
  676. function_name       0449<  0451   0461   0466   0482   0484   0488
  677. hh                  0428<  0429
  678. i                   0181<  0182<  0182   0186<  0186   0190<  0190   0194<
  679.                     0194   0198<  0198   0203<  0203   0208<  0208   0212<
  680.                     0212   0216<  0216   0217<  0217   0218<  0218   0222<
  681.                     0222   0229<  0229   0230<  0230   0231<  0231   0232<
  682.                     0232   0234<  0234   0236<  0236   0238<  0238   0239
  683.                     0241<  0242<  0242   0244<  0244   0246<  0246   0248<
  684.                     0248   0250<  0250   0252<  0252   0254<  0254   0256<
  685.                     0256   0258<  0258   0260<  0260   0262<  0262   0263
  686.                     0315   0368
  687. input_line          0270<  0271   0276   0276   0281   0289
  688. location            0302   0307<  0343
  689. location_option     0297   0299   0301   0307
  690. micro_seconds       0422   0423
  691. minutes             0426<  0427   0428
  692. mm                  0427<  0428   0429
  693. module              0447<  0451   0462   0468   0470   0471   0472<  0472
  694.                     0481   0495
  695. module_fext         0481
  696. module_fname        0481   0482
  697. next_sequence_number
  698.                     0133<  0148<  0153
  699. option              0303   0308<
  700. output_line         0323<  0326   0327<  0330   0331<  0334   0336<  0338
  701.                     0339<  0341   0342<  0344   0345<  0347   0351<  0353
  702.                     0355<  0355   0360<  0360   0362   0364<  0366   0374<
  703.                     0376
  704. program_name        0431<  0432
  705. register_call       0484<  0485
  706. seconds             0422   0424<  0424   0425   0426
  707. sequence_number     0145<  0146   0148
  708. setup_string        0291   0348   0349   0350
  709. setup_string_beg_ptr
  710.                     0276<  0277   0284<  0284   0290
  711. specified_object_id
  712.                     0070   0072   0079   0081<  0082   0084   0086<  0086
  713.                     0089   0400
  714. specified_rc_name   0071   0094   0096<  0099   0104<  0104   0106   0111
  715.                     0402
  716. ss                  0425<  0426   0429
  717. temp_arg            0131<  0132
  718. temp_directory      0119<  0120   0131   0152
  719. temp_stem.0         0134   0135
  720. temp_stem.ts        0136
  721. title               0295   0324   0328   0332   0337
  722. title_class_location_option
  723.                     0290   0292
  724. token               0350   0352
  725. trap_error_description
  726.                     0564<  0570<  0570   0572   0573   0574   0575   0578
  727.                     0580   0582   0583
  728. trap_file_name      0534<  0543<  0547<  0549   0551<  0576   0579   0592
  729.                     0594   0597
  730. trap_source_line    0522<  0529<  0586
  731. ts                  0135
  732. with                0051   0136   0143   0289   0292   0301   0349   0422
  733.                     0532
  734. x                   0557   0558   0559   0560   0561   0562
  735.  
  736. ---- LABELS ----
  737. EOJ                 0166   0390   0412:
  738. ERROR               0036   0510:
  739. FAILURE             0511:
  740. GET_PARAMETERS_INTERACTIVELY
  741.                     0073   0398:
  742. HALT                0037   0512:
  743. NOVALUE             0038   0513:
  744. REGISTER_REQUIRED_FUNCTIONS
  745.                     0063   0441:
  746. REGISTER_ROUTINE    0451   0458:
  747. SYNTAX              0039   0514:
  748. TRAP_PROCESSING     0510   0511   0512   0513   0514   0517:
  749.  
  750. ---- FUNCTIONS ----
  751. ARG                 0416   0419   0522   0541   0565   0567   0569   0571
  752. CENTER              0192   0200   0205   0574   0579
  753. COPIES              0110   0184   0188   0196   0210   0214   0219   0223
  754.                     0324   0332   0351   0364   0572   0573   0578   0582
  755.                     0583
  756. DATATYPE            0146
  757. FILESPEC            0048   0049   0050   0143   0155   0237   0375   0431
  758.                     0470   0471   0472   0532   0534   0535
  759. FORMAT              0425   0427   0428
  760. LASTPOS             0276
  761. LEFT                0047   0079   0336   0339   0342   0345   0355   0423
  762.                     0501
  763. LENGTH              0276   0324   0332   0353   0468   0572   0573   0574
  764.                     0578   0580   0582   0583
  765. LINEIN              0270
  766. LINEOUT             0316   0326   0330   0334   0338   0341   0344   0347
  767.                     0362   0366   0369   0373   0376   0377
  768. LINES               0268
  769. POS                 0099   0271   0299   0519   0549
  770. RIGHT               0084   0145   0153
  771. RxFuncAdd           0482
  772. RxFuncQuery         0466   0545
  773. SOURCELINE          0522
  774. STREAM              0106   0381
  775. STRIP               0142   0471   0522
  776. SysFileDelete       0594
  777. SysFileTree         0132
  778. TIME                0055   0057   0421   0432
  779. TRACE               0406
  780. TRANSLATE           0057   0089   0431   0433
  781. VALUE               0047   0119   0406   0527
  782. VARDUMP             0597
  783. WORD                0486   0486
  784.  
  785. \*-------------------  End of REXX Cross Reference  -------------------*/
  786.