home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / 9603ls01.zip / 9603LS01.CMD next >
OS/2 REXX Batch file  |  1995-12-10  |  54KB  |  808 lines

  1. /*------------------------------------------------------------------------*\
  2. |                                                                          |
  3. |           9603LS01.CMD - Version 1.0 - Version Date 1995-12-02           |
  4. |                 Copyright (C) 1995 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. |                                 - Internet dgoran@cfsrexx.com            |
  10. |                                 - WWW      <http://www.cfsrexx.com>      |
  11. |                                                                          |
  12. | ------------------------------------------------------------------------ |
  13. |                Requires: WPTOOLS.DLL  - (c) Henk Kelder                  |
  14. \*------------------------------------------------------------------------*/
  15. /*
  16.  
  17.    Add all Connect-related .INF and .HLP files on the boot drive that
  18.    are not currently referenced in <WP_INFO> or certain other folders to
  19.    a the <WP_INFO> folder (.INF) or a new folder (.HLP).
  20.  
  21.    A description of this program is contained in The REXX Column, OS/2
  22.    Magazine - March, 1996. (h:\os2-mag\9603ls01.cmd)
  23.  
  24. */                                                                /* 0024 */
  25. GBL. = ''             /* initialize stem */                       /* 0025 */
  26. parse Arg             GBL.command_line                            /* 0026 */
  27. parse Version         GBL.REXX_version,                           /* 0027 */
  28.                       GBL.REXX_version_level,                     /* 0028 */
  29.                       GBL.REXX_version_day,                       /* 0029 */
  30.                       GBL.REXX_version_month,                     /* 0030 */
  31.                       GBL.REXX_version_year .                     /* 0031 */
  32. parse upper Source    GBL.operating_system,                       /* 0032 */
  33.                       GBL.calling_environment,                    /* 0033 */
  34.                       GBL.program_path_and_name                   /* 0034 */
  35. GBL.environment     = 'OS2ENVIRONMENT'                            /* 0035 */
  36. GBL.boot_drive      = LEFT( VALUE( 'RUNWORKPLACE',, GBL.environment ), 2 )
  37. GBL.program_version = 1.0           /* version / mod of this program */
  38. GBL.program_name    = STRIP( FILESPEC( 'N', GBL.program_path_and_name ) )
  39. GBL.program_path    = STRIP( FILESPEC( 'D', GBL.program_path_and_name ) ||,
  40.                              FILESPEC( 'P', GBL.program_path_and_name ) )
  41.                                                                   /* 0041 */
  42. parse var GBL.program_name,                                       /* 0042 */
  43.    GBL.program_fn '.',                                            /* 0043 */
  44.    GBL.program_fe                                                 /* 0044 */
  45. call TIME 'E'                       /* set elapsed timer - sssss.uuuuu */
  46. say 'Begin' GBL.program_name 'at' TIME('N')                       /* 0046 */
  47.                                                                   /* 0047 */
  48. /*---------------*\                                               /* 0048 */
  49. |  Register APIs  |                                               /* 0049 */
  50. \*---------------*/                                               /* 0050 */
  51. /* REXXUTIL */                                                    /* 0051 */
  52. if RxFuncQuery( 'SysLoadFuncs' ) ¬= 0 then                        /* 0052 */
  53.    do                                                             /* 0053 */
  54.       call RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs'   /* 0054 */
  55.       call SysLoadFuncs                                           /* 0055 */
  56.    end                                                            /* 0056 */
  57.                                                                   /* 0057 */
  58. /* WPTOOLS */                                                     /* 0058 */
  59. if RxFuncQuery( 'WPToolsLoadFuncs' ) ¬= 0 then                    /* 0059 */
  60.    do                                                             /* 0060 */
  61.       call RxFuncAdd 'WPToolsLoadFuncs', 'WPTOOLS', 'WPToolsLoadFuncs'
  62.       call WPToolsLoadFuncs                                       /* 0062 */
  63.    end                                                            /* 0063 */
  64.                                                                   /* 0064 */
  65. /*------------------------*\                                      /* 0065 */
  66. |  Enable trap processing  |                                      /* 0066 */
  67. |    if REXXLIB present    |                                      /* 0067 */
  68. \*------------------------*/                                      /* 0068 */
  69.    SIGNAL ON ERROR                                                /* 0069 */
  70.    SIGNAL ON FAILURE                                              /* 0070 */
  71.    SIGNAL ON HALT                                                 /* 0071 */
  72.    SIGNAL ON NOVALUE                                              /* 0072 */
  73.    SIGNAL ON SYNTAX                                               /* 0073 */
  74.                                                                   /* 0074 */
  75. /*----------------------*\                                        /* 0075 */
  76. |  Miscellaneous values  |                                        /* 0076 */
  77. \*----------------------*/                                        /* 0077 */
  78. GBL.connect_related_directories =,                                /* 0078 */
  79.    'GRPWARE',                                                     /* 0079 */
  80.    'IBMCOM',                                                      /* 0080 */
  81.    'IBMLAN',                                                      /* 0081 */
  82.    'LANLK',                                                       /* 0082 */
  83.    'MPTN',                                                        /* 0083 */
  84.    'MUGLIB',                                                      /* 0084 */
  85.    'NSC',                                                         /* 0085 */
  86.    'TCPIP',                                                       /* 0086 */
  87.    'WAL',                                                         /* 0087 */
  88.    ''                                                             /* 0088 */
  89.                                                                   /* 0089 */
  90. p=0                                                               /* 0090 */
  91. p=p+1; GBL.path_list.p = TRANSLATE( VALUE( 'BOOKSHELF',, GBL.environment) )
  92. p=p+1; GBL.path_list.p = TRANSLATE( VALUE( 'HELP',,      GBL.environment) )
  93. p=p+1; GBL.path_list.p = TRANSLATE( VALUE( 'ETC',,       GBL.environment) )
  94. p=p+1; GBL.path_list.p = TRANSLATE( VALUE( 'DPATH',,     GBL.environment) )
  95. p=p+1; GBL.path_list.p = TRANSLATE( VALUE( 'PATH',,      GBL.environment) )
  96.        GBL.path_list.0 = p                                        /* 0096 */
  97.                                                                   /* 0097 */
  98. GBL.warp        = ( RxFuncQuery( 'SysMoveObject' ) = 0 )          /* 0098 */
  99. GBL.warp_peer   = ( SysIni( 'USER', 'PM_Workplace:Location', 'WP_PEER' ) ¬= '' )
  100.                                                                   /* 0100 */
  101. lowercase     ='abcdefghijklmnopqrstuvwxyz'                       /* 0101 */
  102. uppercase     ='ABCDEFGHIJKLMNOPQRSTUVWXYZ'                       /* 0102 */
  103.                                                                   /* 0103 */
  104. view_path_and_file_name =,                                        /* 0104 */
  105.    SysSearchPath( 'PATH', 'VIEW.EXE' )                            /* 0105 */
  106. viewhelp_path_and_file_name =,                                    /* 0106 */
  107.    SysSearchPath( 'PATH', 'VIEWHELP.EXE' )                        /* 0107 */
  108.                                                                   /* 0108 */
  109. /*------------------------------------------------------------*\  /* 0109 */
  110. |  Get current contents of the Information (<WP_INFO>) folder  |  /* 0110 */
  111. \*------------------------------------------------------------*/  /* 0111 */
  112. /* info_stem will contain either an object ID or a handle */      /* 0112 */
  113. info_object_id = '<WP_INFO>'                                      /* 0113 */
  114.                                                                   /* 0114 */
  115. say '   Extracting contents of' info_object_id                    /* 0115 */
  116. call WPToolsFolderContent info_object_id, 'info_stem'             /* 0116 */
  117. if RESULT ¬= 1 then                                               /* 0117 */
  118.    do                                                             /* 0118 */
  119.       say '   Unable to get contents of' info_object_id           /* 0119 */
  120.       call EOJ                                                    /* 0120 */
  121.    end                                                            /* 0121 */
  122.                                                                   /* 0122 */
  123. /*---------------------------------------------------------*\     /* 0123 */
  124. |  Extract name of .INF or .HLP file from <WP_INFO> object  |     /* 0124 */
  125. \*---------------------------------------------------------*/     /* 0125 */
  126. existing_inf_hlp_table. = ''        /* associative array of INF & HLP files */
  127.                                                                   /* 0127 */
  128. do i = 1 to info_stem.0                                           /* 0128 */
  129.                                                                   /* 0129 */
  130.    /*---------------------------------------------*\              /* 0130 */
  131.    |  Get contents (i.e. setup string) for object  |              /* 0131 */
  132.    \*---------------------------------------------*/              /* 0132 */
  133.    call WPToolsQueryObject info_stem.i, 'class', 'title', 'setup', 'location'
  134.    if RESULT ¬= 1 then                                            /* 0134 */
  135.       do                                                          /* 0135 */
  136.          say '   Unable to retrieve contents of' info_stem.i      /* 0136 */
  137.          iterate i                                                /* 0137 */
  138.       end                                                         /* 0138 */
  139.                                                                   /* 0139 */
  140.    /*-------------------------------------------------------*\    /* 0140 */
  141.    |  Find .INF file name used as parameter to VIEW.EXE      |    /* 0141 */
  142.    |                         or                              |    /* 0142 */
  143.    |       .HLP file name used as parameter to VIEWHELP.EXE  |    /* 0143 */
  144.    \*-------------------------------------------------------*/    /* 0144 */
  145.    uppercase_setup = TRANSLATE( setup )                           /* 0145 */
  146.    implied_file_extension = ''                                    /* 0146 */
  147.    select                                                         /* 0147 */
  148.       when POS( 'EXENAME=VIEWHELP', uppercase_setup ) > 0 then    /* 0148 */
  149.          do                                                       /* 0149 */
  150.             implied_file_extension = 'HLP'                        /* 0150 */
  151.          end                                                      /* 0151 */
  152.       when POS( 'EXENAME=VIEW', uppercase_setup ) > 0 then        /* 0152 */
  153.          do                                                       /* 0153 */
  154.             implied_file_extension = 'INF'                        /* 0154 */
  155.          end                                                      /* 0155 */
  156.       otherwise                                                   /* 0156 */
  157.          do                                                       /* 0157 */
  158.             iterate i                                             /* 0158 */
  159.          end                                                      /* 0159 */
  160.    end                                                            /* 0160 */
  161.                                                                   /* 0161 */
  162.    /*---------------------------------*\                          /* 0162 */
  163.    |  Get file name used as parameter  |                          /* 0163 */
  164.    \*---------------------------------*/                          /* 0164 */
  165.    parse value uppercase_setup with,                              /* 0165 */
  166.       'PARAMETERS=',                                              /* 0166 */
  167.       parameter_value,                                            /* 0167 */
  168.       ';'                                                         /* 0168 */
  169.    parse value FILESPEC( 'N', parameter_value ) with,             /* 0169 */
  170.       parameter_fn,                                               /* 0170 */
  171.       '.',                                                        /* 0171 */
  172.       parameter_fext                                              /* 0172 */
  173.    select                                                         /* 0173 */
  174.       when parameter_fext = '' then                               /* 0174 */
  175.          do                                                       /* 0175 */
  176.             /* supply implied file extension */                   /* 0176 */
  177.             parameter_value =,                                    /* 0177 */
  178.                parameter_value || '.' || implied_file_extension   /* 0178 */
  179.          end                                                      /* 0179 */
  180.       when WORDS( parameter_fext ) > 1 then                       /* 0180 */
  181.          do                                                       /* 0181 */
  182.             /* drop additional parameters */                      /* 0182 */
  183.             parameter_fext =,                                     /* 0183 */
  184.                WORD( parameter_fext, 1 )                          /* 0184 */
  185.             parameter_value =,                                    /* 0185 */
  186.                parameter_fn || '.' || parameter_fext              /* 0186 */
  187.          end                                                      /* 0187 */
  188.       otherwise                                                   /* 0188 */
  189.          nop                                                      /* 0189 */
  190.    end                                                            /* 0190 */
  191.                                                                   /* 0191 */
  192.    /*------------------------------------------------------*\     /* 0192 */
  193.    |  Add full path of INF / HLP file to associative array  |     /* 0193 */
  194.    |  of objects referenced with Information folder         |     /* 0194 */
  195.    \*------------------------------------------------------*/     /* 0195 */
  196.    /* SysSearchPath() can not be used */                          /* 0196 */
  197.    parameter_path =,                                              /* 0197 */
  198.       FILESPEC( 'D', parameter_value ) ||,                        /* 0198 */
  199.       FILESPEC( 'P', parameter_value )                            /* 0199 */
  200.    if parameter_path ¬= '' then                                   /* 0200 */
  201.       do                                                          /* 0201 */
  202.          existing_inf_hlp_table.PARAMETER_VALUE = i               /* 0202 */
  203.       end                                                         /* 0203 */
  204.    else                                                           /* 0204 */
  205.       do                                                          /* 0205 */
  206.          say COPIES( ' ', 6 ) || 'Searching for path for' parameter_value
  207.          call ADD_FULL_PATHED_INF_HLP_TO_ASSOCIATIVE_ARRAY parameter_value
  208.       end                                                         /* 0208 */
  209.                                                                   /* 0209 */
  210. end                                                               /* 0210 */
  211.                                                                   /* 0211 */
  212. /*------------------------------------------------------------------------*\
  213. |                                                                          |
  214. |     Build combined stem of all .INF & .HLP files in Connect-related      |
  215. |                               directories                                |
  216. |                                                                          |
  217. \*------------------------------------------------------------------------*/
  218. combined_stem.0 = 0                                               /* 0218 */
  219.                                                                   /* 0219 */
  220. do w = 1 to WORDS( GBL.connect_related_directories )              /* 0220 */
  221.    directory = WORD( GBL.connect_related_directories, w )         /* 0221 */
  222.    call ADD_HLP_INF_FILES_TO_COMBINED_STEM directory              /* 0222 */
  223. end                                                               /* 0223 */
  224.                                                                   /* 0224 */
  225. /*---------------------------------*\                             /* 0225 */
  226. |  Folder object for new HLP files  |                             /* 0226 */
  227. \*---------------------------------*/                             /* 0227 */
  228. hlp_folder_location = '<WP_DESKTOP>'                              /* 0228 */
  229. hlp_folder_class    = 'WPFolder'                                  /* 0229 */
  230. hlp_folder_title    = 'Connect related^HLP Files'                 /* 0230 */
  231. hlp_folder_setup    =,                                            /* 0231 */
  232.    'ALWAYSSORT=YES;'                        ||,                   /* 0232 */
  233.    'ICONVIEW=FLOWED,MINI;'                  ||,                   /* 0233 */
  234.    'OBJECTID=<' || hlp_folder_title || '>;' ||,                   /* 0234 */
  235.    ''                                                             /* 0235 */
  236. call SysCreateObject hlp_folder_class,,                           /* 0236 */
  237.                      hlp_folder_title,,                           /* 0237 */
  238.                      hlp_folder_location,,                        /* 0238 */
  239.                      hlp_folder_setup,,                           /* 0239 */
  240.                      'REPLACE'                                    /* 0240 */
  241.                                                                   /* 0241 */
  242.                                                                   /* 0242 */
  243. /*---------------------------------*\                             /* 0243 */
  244. |  WPProgram setup for new objects  |                             /* 0244 */
  245. \*---------------------------------*/                             /* 0245 */
  246. hlp_location     = '<' || hlp_folder_title || '>'                 /* 0246 */
  247. inf_location     = '<WP_INFO>'                                    /* 0247 */
  248.                                                                   /* 0248 */
  249. /*------------------------------------------*\                    /* 0249 */
  250. |  Compare INF / HLP files with contents of  |                    /* 0250 */
  251. |  WP_INFO folder and add non-existing item  |                    /* 0251 */
  252. |  to new folder on Desktop                  |                    /* 0252 */
  253. \*------------------------------------------*/                    /* 0253 */
  254. say '   Adding new objects to' inf_location '/' hlp_location      /* 0254 */
  255. new_object_count = 0                                              /* 0255 */
  256. do i = 1 to combined_stem.0                                       /* 0256 */
  257.                                                                   /* 0257 */
  258.    parse upper value combined_stem.i with,                        /* 0258 */
  259.       inf_hlp_date,                                               /* 0259 */
  260.       inf_hlp_time,                                               /* 0260 */
  261.       inf_hlp_size,                                               /* 0261 */
  262.       inf_hlp_attr,                                               /* 0262 */
  263.       inf_hlp_path_and_file_name                                  /* 0263 */
  264.    inf_hlp_path_and_file_name = STRIP( inf_hlp_path_and_file_name )
  265.                                                                   /* 0265 */
  266.    /*-------------------------------------*\                      /* 0266 */
  267.    |  Ignore entries alreday in <WP_INFO>  |                      /* 0267 */
  268.    |  or other specific directories        |                      /* 0268 */
  269.    \*-------------------------------------*/                      /* 0269 */
  270.    if existing_inf_hlp_table.INF_HLP_PATH_AND_FILE_NAME ¬= '' then
  271.       do                                                          /* 0271 */
  272.          iterate i                                                /* 0272 */
  273.       end                                                         /* 0273 */
  274.                                                                   /* 0274 */
  275.    /*-------------------------------------*\                      /* 0275 */
  276.    |  Extract title from .INF / .HLP file  |                      /* 0276 */
  277.    \*-------------------------------------*/                      /* 0277 */
  278.    call STREAM inf_hlp_path_and_file_name, 'C', 'OPEN READ'       /* 0278 */
  279.    inf_hlp_area = CHARIN( inf_hlp_path_and_file_name, 1, 512)     /* 0279 */
  280.    call STREAM inf_hlp_path_and_file_name, 'C', 'CLOSE'           /* 0280 */
  281.                                                                   /* 0281 */
  282.    if LEFT( inf_hlp_area, 3 ) ¬= 'HSP' then                       /* 0282 */
  283.       do                                                          /* 0283 */
  284.          /* ignore unrecognizeable format */                      /* 0284 */
  285.          iterate i                                                /* 0285 */
  286.       end                                                         /* 0286 */
  287.    hold_area = SUBSTR( inf_hlp_area, 108, 256 ) /* short for performance */
  288.    parse value hold_area with,                                    /* 0288 */
  289.       inf_hlp_title,                                              /* 0289 */
  290.       '00'x                                                       /* 0290 */
  291.                                                                   /* 0291 */
  292.    /*----------------------------------------------------*\       /* 0292 */
  293.    |  Edit title removing any necessary punctuation       |       /* 0293 */
  294.    |  and adding file system name as second or only line  |       /* 0294 */
  295.    \*----------------------------------------------------*/       /* 0295 */
  296.    remove_characters = '<>*";'                                    /* 0296 */
  297.    inf_hlp_title =,                                               /* 0297 */
  298.       SPACE( TRANSLATE( inf_hlp_title,,                           /* 0298 */
  299.                         COPIES( ' ', LENGTH(remove_characters) ),,
  300.                         remove_characters ) )                     /* 0300 */
  301.    if inf_hlp_title ¬= '' then                                    /* 0301 */
  302.       do                                                          /* 0302 */
  303.          inf_hlp_title =,                                         /* 0303 */
  304.             inf_hlp_title || '^' /* force second line */          /* 0304 */
  305.       end                                                         /* 0305 */
  306.    inf_hlp_title =,                                               /* 0306 */
  307.       inf_hlp_title                                      ||,      /* 0307 */
  308.       '(' || TRANSLATE( inf_hlp_path_and_file_name,,              /* 0308 */
  309.                         lowercase, uppercase ) || ')'             /* 0309 */
  310.                                                                   /* 0310 */
  311.    /*-------------------------------------------*\                /* 0311 */
  312.    |  Build WPProgram object for INF / HLP file  |                /* 0312 */
  313.    \*-------------------------------------------*/                /* 0313 */
  314.    if RIGHT( inf_hlp_path_and_file_name, 4 ) = '.HLP' then        /* 0314 */
  315.       do                                                          /* 0315 */
  316.          exe_name  = viewhelp_path_and_file_name                  /* 0316 */
  317.          location  = hlp_location                                 /* 0317 */
  318.          object_id = ''                                           /* 0318 */
  319.       end                                                         /* 0319 */
  320.    else                                                           /* 0320 */
  321.       do                                                          /* 0321 */
  322.          exe_name  = view_path_and_file_name                      /* 0322 */
  323.          location  = inf_location                                 /* 0323 */
  324.          object_id = 'OBJECTID=<' || inf_hlp_title || '>;'        /* 0324 */
  325.       end                                                         /* 0325 */
  326.    setup_string =,                                                /* 0326 */
  327.       'CCVIEW=NO;'                                          ||,   /* 0327 */
  328.       'ICONRESOURCE=60 PMWP;'                               ||,   /* 0328 */
  329.       'EXENAME=' || exe_name || ';'                         ||,   /* 0329 */
  330.       'PARAMETERS=' || inf_hlp_path_and_file_name || ';'    ||,   /* 0330 */
  331.       object_id                                             ||,   /* 0331 */
  332.       ''                                                          /* 0332 */
  333.                                                                   /* 0333 */
  334.    new_object_count = new_object_count + 1                        /* 0334 */
  335.    say COPIES( ' ', 6 ) || 'Adding:' inf_hlp_title                /* 0335 */
  336.    call SysCreateObject 'WPProgram',,                             /* 0336 */
  337.                         inf_hlp_title,,                           /* 0337 */
  338.                         location,,                                /* 0338 */
  339.                         setup_string,                             /* 0339 */
  340.                         'UPDATE'                                  /* 0340 */
  341.    if RESULT ¬= 1 then                                            /* 0341 */
  342.       do                                                          /* 0342 */
  343.          say '   Unable to create object for' inf_hlp_title       /* 0343 */
  344.       end                                                         /* 0344 */
  345.                                                                   /* 0345 */
  346. end                                                               /* 0346 */
  347.                                                                   /* 0347 */
  348. /*--------------------------*\                                    /* 0348 */
  349. |  Show total new objects &  |                                    /* 0349 */
  350. |  open folders              |                                    /* 0350 */
  351. \*--------------------------*/                                    /* 0351 */
  352. if new_object_count > 0 then                                      /* 0352 */
  353.    do                                                             /* 0353 */
  354.       say COPIES( ' ', 3 ) ||,                                    /* 0354 */
  355.           new_object_count ||,                                    /* 0355 */
  356.           ' new objects added to' inf_location '/' hlp_location   /* 0356 */
  357.       call SysOpenObject inf_location, 1, 1                       /* 0357 */
  358.       call SysOpenObject hlp_location, 1, 1                       /* 0358 */
  359.    end                                                            /* 0359 */
  360.                                                                   /* 0360 */
  361. call EOJ 0                                                        /* 0361 */
  362.                                                                   /* 0362 */
  363. /*------------------------------------------------------------------------*\
  364. |                                                                          |
  365. |                Add .INF / .HLP file to associative array                 |
  366. |                                                                          |
  367. \*------------------------------------------------------------------------*/
  368. ADD_FULL_PATHED_INF_HLP_TO_ASSOCIATIVE_ARRAY:                     /* 0368 */
  369.    Procedure expose,                                              /* 0369 */
  370.       GBL. existing_inf_hlp_table.                                /* 0370 */
  371.                                                                   /* 0371 */
  372. fn_fext = ARG(1)                                                  /* 0372 */
  373.                                                                   /* 0373 */
  374. do p = 1 to GBL.path_list.0                                       /* 0374 */
  375.    path_names = GBL.path_list.p                                   /* 0375 */
  376.    do while path_names ¬= ''                                      /* 0376 */
  377.       parse value path_names with,                                /* 0377 */
  378.          token,                                                   /* 0378 */
  379.          ';',                                                     /* 0379 */
  380.          path_names                                               /* 0380 */
  381.       call SysFileTree token || '\' || fn_fext, 'temp_stem', 'O'  /* 0381 */
  382.       if temp_stem.0 = 1 then                                     /* 0382 */
  383.          do                                                       /* 0383 */
  384.             full_pathed_name = TRANSLATE( temp_stem.1 )           /* 0384 */
  385.             existing_inf_hlp_table.FULL_PATHED_NAME = '*'         /* 0385 */
  386.             return                                                /* 0386 */
  387.          end                                                      /* 0387 */
  388.    end                                                            /* 0388 */
  389. end                                                               /* 0389 */
  390. return                                                            /* 0390 */
  391.                                                                   /* 0391 */
  392.                                                                   /* 0392 */
  393. /*------------------------------------------------------------------------*\
  394. |                                                                          |
  395. |                  Add INF & HLP files to a combined stem                  |
  396. |                                                                          |
  397. \*------------------------------------------------------------------------*/
  398. ADD_HLP_INF_FILES_TO_COMBINED_STEM:                               /* 0398 */
  399.    Procedure expose,                                              /* 0399 */
  400.       GBL. combined_stem.                                         /* 0400 */
  401.                                                                   /* 0401 */
  402. directory = '\' || ARG( 1 )                                       /* 0402 */
  403.                                                                   /* 0403 */
  404. /*---------------------------------------*\                       /* 0404 */
  405. |  Find drive for specified path (Assume  |                       /* 0405 */
  406. |  BOOK & HELP to be the same drive)      |                       /* 0406 */
  407. \*---------------------------------------*/                       /* 0407 */
  408. drive_letter_colon = ''                                           /* 0408 */
  409. do p = 1 to GBL.path_list.0                                       /* 0409 */
  410.    ptr = POS( directory, GBL.path_list.p )                        /* 0410 */
  411.    if ptr > 0 then                                                /* 0411 */
  412.       do                                                          /* 0412 */
  413.          drive_letter_colon =,                                    /* 0413 */
  414.             SUBSTR( GBL.path_list.p, ptr - 2, 2 )                 /* 0414 */
  415.          leave p                                                  /* 0415 */
  416.       end                                                         /* 0416 */
  417. end                                                               /* 0417 */
  418.                                                                   /* 0418 */
  419. if drive_letter_colon = '' then                                   /* 0419 */
  420.    do                                                             /* 0420 */
  421.       say '   Unable to locate path of' directory                 /* 0421 */
  422.       return                                                      /* 0422 */
  423.    end                                                            /* 0423 */
  424.                                                                   /* 0424 */
  425. call SysFileTree drive_letter_colon ||directory || '\*.*',,       /* 0425 */
  426.                  'temp_stem', 'FS'                                /* 0426 */
  427.                                                                   /* 0427 */
  428. do t = 1 to temp_stem.0                                           /* 0428 */
  429.    parse upper value temp_stem.t with,                            /* 0429 */
  430.       temp_date,                                                  /* 0430 */
  431.       temp_time,                                                  /* 0431 */
  432.       temp_size,                                                  /* 0432 */
  433.       temp_attr,                                                  /* 0433 */
  434.       temp_path_and_file_name                                     /* 0434 */
  435.    temp_path_and_file_name = STRIP( temp_path_and_file_name )     /* 0435 */
  436.                                                                   /* 0436 */
  437.    temp_file_extension = RIGHT( temp_path_and_file_name, 3 )      /* 0437 */
  438.    if temp_file_extension ¬= 'HLP',                               /* 0438 */
  439.          &,                                                       /* 0439 */
  440.       temp_file_extension ¬= 'INF' then                           /* 0440 */
  441.       do                                                          /* 0441 */
  442.          iterate t                                                /* 0442 */
  443.       end                                                         /* 0443 */
  444.                                                                   /* 0444 */
  445.    c = combined_stem.0 + 1                                        /* 0445 */
  446.    combined_stem.0 = c                                            /* 0446 */
  447.    combined_stem.c = temp_stem.t                                  /* 0447 */
  448. end                                                               /* 0448 */
  449.                                                                   /* 0449 */
  450. return                                                            /* 0450 */
  451.                                                                   /* 0451 */
  452. /*------------------------------------------------------------------------*\
  453. |                                                                          |
  454. |                                End of Job                                |
  455. |                                                                          |
  456. \*------------------------------------------------------------------------*/
  457. EOJ:                                                              /* 0457 */
  458.    Procedure expose,                                              /* 0458 */
  459.       GBL.                                                        /* 0459 */
  460.                                                                   /* 0460 */
  461. if ARG() = 0 then                                                 /* 0461 */
  462.    eoj_rc = 0                                                     /* 0462 */
  463. else                                                              /* 0463 */
  464.    eoj_rc = ARG(1)                                                /* 0464 */
  465.                                                                   /* 0465 */
  466. elapsed_time = TIME('E')            /* get elapsed time - sssss.uuuuu */
  467. parse value elapsed_time with seconds '.' micro_seconds           /* 0467 */
  468. if LEFT( micro_seconds, 1, 1 ) >= 5 then                          /* 0468 */
  469.    seconds = seconds + 1                                          /* 0469 */
  470. ss = FORMAT( seconds // 60, 2 )                                   /* 0470 */
  471. minutes = ( seconds - ss ) / 60                                   /* 0471 */
  472. mm = FORMAT( minutes // 60, 2 )                                   /* 0472 */
  473. hh = FORMAT( ( minutes - mm ) / 60, 2 )                           /* 0473 */
  474. duration = hh':'mm':'ss                                           /* 0474 */
  475.                                                                   /* 0475 */
  476. program_name = TRANSLATE( FILESPEC( 'N', GBL.program_path_and_name ) )
  477. say 'EOJ  ' program_name 'at' TIME('N') ||,                       /* 0477 */
  478.     ', duration' TRANSLATE( duration, '0', ' ' )                  /* 0478 */
  479. exit eoj_rc                                                       /* 0479 */
  480.                                                                   /* 0480 */
  481.                                                                   /* 0481 */
  482. !tr!=VALUE('TRACE',,'OS2Environment'); if !tr!<>'' then do;TRACE(!tr!);nop;end
  483. /*------------------------------------------------------------------------*\
  484. |                                                                          |
  485. |                              Trap Routines                               |
  486. |                                                                          |
  487. \*------------------------------------------------------------------------*/
  488. ERROR:   call TRAP_PROCESSING SIGL, 'ERROR',   RC                 /* 0488 */
  489. FAILURE: call TRAP_PROCESSING SIGL, 'FAILURE', RC                 /* 0489 */
  490. HALT:    call TRAP_PROCESSING SIGL, 'HALT',    ''                 /* 0490 */
  491. NOVALUE: call TRAP_PROCESSING SIGL, 'NOVALUE', ''                 /* 0491 */
  492. SYNTAX:  call TRAP_PROCESSING SIGL, 'SYNTAX',  RC                 /* 0492 */
  493.                                                                   /* 0493 */
  494. /* Rev. 95/10/14 */                                               /* 0494 */
  495. TRAP_PROCESSING:                                                  /* 0495 */
  496.    parse Source . . TRAP.path_and_program                         /* 0496 */
  497.    trap.line_nbr = ARG(1)                                         /* 0497 */
  498.    if POS( ':', TRAP.path_and_program ) > 0 then                  /* 0498 */
  499.       /* get source line if it is available */                    /* 0499 */
  500.       do t = 1                                                    /* 0500 */
  501.          trap_source_line.t =  SOURCELINE( trap.line_nbr )        /* 0501 */
  502.          trap_source_line.0 = t                                   /* 0502 */
  503.          trap.line_nbr      = trap.line_nbr + 1                   /* 0503 */
  504.          if RIGHT( trap_source_line.t, 1 ) ¬= ',' then            /* 0504 */
  505.             do                                                    /* 0505 */
  506.                leave                                              /* 0506 */
  507.             end                                                   /* 0507 */
  508.       end                                                         /* 0508 */
  509.    else                                                           /* 0509 */
  510.       /* program is running in macrospace */                      /* 0510 */
  511.       do                                                          /* 0511 */
  512.          TRAP.path_and_program = STRIP( DIRECTORY(), 'T', '\' ) || '\' ||,
  513.                                  TRAP.path_and_program            /* 0513 */
  514.          trap_source_line.1 = 'Source line is not available.'     /* 0514 */
  515.          trap_source_line.0 = 1                                   /* 0515 */
  516.       end                                                         /* 0516 */
  517.                                                                   /* 0517 */
  518.    parse value FILESPEC( 'N', TRAP.path_and_program ) with,       /* 0518 */
  519.       TRAP.fn '.' TRAP.fe                                         /* 0519 */
  520.    trap_file_name = FILESPEC( 'D', TRAP.path_and_program ) ||,    /* 0520 */
  521.                     FILESPEC( 'P', TRAP.path_and_program ) ||,    /* 0521 */
  522.                     TRAP.fn || '.' || 'DMP'                       /* 0522 */
  523.                                                                   /* 0523 */
  524.    /*------------------------------------------*\                 /* 0524 */
  525.    |  check for reason not to create .DMP file  |                 /* 0525 */
  526.    \*------------------------------------------*/                 /* 0526 */
  527.    if ARG(2) = 'HALT' then                                        /* 0527 */
  528.       do                                                          /* 0528 */
  529.          trap_file_name = ''                                      /* 0529 */
  530.       end                                                         /* 0530 */
  531.    if RxFuncQuery( 'VARDUMP' ) <> 0 then                          /* 0531 */
  532.       do                                                          /* 0532 */
  533.          trap_file_name = ''                                      /* 0533 */
  534.       end                                                         /* 0534 */
  535.    if POS( ':', trap_file_name ) = 0 then                         /* 0535 */
  536.       do                                                          /* 0536 */
  537.          trap_file_name = ''                                      /* 0537 */
  538.       end                                                         /* 0538 */
  539.                                                                   /* 0539 */
  540.    /*------------------------*\                                   /* 0540 */
  541.    |  Build trap message box  |                                   /* 0541 */
  542.    \*------------------------*/                                   /* 0542 */
  543.    dbl.h    = 'CD'x                 /* ═ double line - horizontal   */
  544.    dbl.v    = 'BA'x                 /* ║ double line - vertical     */
  545.    dbl.bl   = 'C8'x                 /* ╚ double line - bottom left  */
  546.    dbl.br   = 'BC'x                 /* ╝ double line - bottom right */
  547.    dbl.tl   = 'C9'x                 /* ╔ double line - top left     */
  548.    dbl.tr   = 'BB'x                 /* ╗ double line - top right    */
  549.    trap.red = '1B'x || '[1;37;41m'  /* bright white on red          */
  550.    trap.dul = '1B'x || '[0m'        /* reset to normal              */
  551.                                                                   /* 0551 */
  552.    say ' '                                                        /* 0552 */
  553.    trap_error_description =,                                      /* 0553 */
  554.       'Error line = ' || ARG(1) ||,                               /* 0554 */
  555.       '; ' ||,                                                    /* 0555 */
  556.       ARG(2) ||,                                                  /* 0556 */
  557.       ' error.'                                                   /* 0557 */
  558.    if ARG(3) <> '' then                                           /* 0558 */
  559.       trap_error_description = trap_error_description ||,         /* 0559 */
  560.                                '  Return code = ' || ARG(3)       /* 0560 */
  561.    trap.width = MAX( 74, LENGTH( trap_error_description ) )       /* 0561 */
  562.    say trap.red || dbl.tl || COPIES( dbl.h,trap.width + 2 ) || dbl.tr || trap.dul
  563.    say trap.red || dbl.v  || COPIES( ' ',  trap.width + 2 ) || dbl.v  || trap.dul
  564.    say trap.red || dbl.v CENTER( TRAP.fn'.'TRAP.fe,trap.width )    dbl.v  || trap.dul
  565.    say trap.red || dbl.v CENTER( trap_error_description, trap.width ) dbl.v || trap.dul
  566.    if trap_file_name <> '' then                                   /* 0566 */
  567.       do                                                          /* 0567 */
  568.    say trap.red || dbl.v  || COPIES( ' ',  trap.width + 2 ) || dbl.v  || trap.dul
  569.    say trap.red || dbl.v     CENTER( 'See: ' || trap_file_name,,  /* 0569 */
  570.                                      trap.width )  dbl.v  || trap.dul
  571.       end                                                         /* 0571 */
  572.    say trap.red || dbl.v  || COPIES( ' ',  trap.width + 2 ) || dbl.v  || trap.dul
  573.    say trap.red || dbl.bl || COPIES( dbl.h,trap.width + 2 ) || dbl.br || trap.dul
  574.    say trap.red || COPIES( ' ', trap.width + 4 ) || trap.dul      /* 0574 */
  575.    say trap.red || LEFT( 'Source line(s) at time of trap:', trap.width + 4 ) || trap.dul
  576.    do t = 1 to trap_source_line.0                                 /* 0576 */
  577.       say trap.red || LEFT( '   ' || trap_source_line.t, trap.width + 4 ) || trap.dul
  578.    end                                                            /* 0578 */
  579.    say trap.red || COPIES( ' ', trap.width + 4 ) || trap.dul      /* 0579 */
  580.                                                                   /* 0580 */
  581.    /*---------------------------------*\                          /* 0581 */
  582.    |  Create .DMP file if appropriate  |                          /* 0582 */
  583.    \*---------------------------------*/                          /* 0583 */
  584.    if trap_file_name <> '' then                                   /* 0584 */
  585.       do                                                          /* 0585 */
  586.          call SysFileDelete trap_file_name                        /* 0586 */
  587.          /* remove meaningless labels from dump for clarity */    /* 0587 */
  588.          drop dbl. TRAP. RC RESULT SIGL !tr!                      /* 0588 */
  589.          call VARDUMP trap_file_name  /* write variables to program.DMP file */
  590.       end                                                         /* 0590 */
  591.    exit 253                                                       /* 0591 */
  592. /*---------  REXX Cross Reference  - Created: 12/10/95 4:54pm ----------*\
  593.        H:\OS2-MAG\9603LS01.CMD - Directory time stamp 12/10/95 4:52p
  594.  
  595. ---- VARIABLES ----
  596. !tr!                0482<  0482   0482   0588
  597. GBL.                0025<  0370   0400   0459
  598. GBL.REXX_version    0027
  599. GBL.REXX_version_day
  600.                     0029
  601. GBL.REXX_version_level
  602.                     0028
  603. GBL.REXX_version_month
  604.                     0030
  605. GBL.REXX_version_year
  606.                     0031
  607. GBL.boot_drive      0036<
  608. GBL.calling_environment
  609.                     0033
  610. GBL.command_line    0026
  611. GBL.connect_related_directories
  612.                     0078<  0220   0221
  613. GBL.environment     0035<  0036   0091   0092   0093   0094   0095
  614. GBL.operating_system
  615.                     0032
  616. GBL.path_list.0     0096<  0374   0409
  617. GBL.path_list.p     0091<  0092<  0093<  0094<  0095<  0375   0410   0414
  618. GBL.program_fe      0044
  619. GBL.program_fn      0043
  620. GBL.program_name    0038<  0042   0046
  621. GBL.program_path    0039<
  622. GBL.program_path_and_name
  623.                     0034   0038   0039   0040   0476
  624. GBL.program_version
  625.                     0037<
  626. GBL.warp            0098<
  627. GBL.warp_peer       0099<
  628. RC                  0488   0489   0492   0588
  629. RESULT              0117   0134   0341   0588
  630. SIGL                0488   0489   0490   0491   0492   0588
  631. TRAP.               0588
  632. TRAP.fe             0519   0564
  633. TRAP.fn             0519   0522   0564
  634. TRAP.path_and_program
  635.                     0496   0498   0512<  0513   0518   0520   0521
  636. Version             0027
  637. c                   0445<  0446
  638. combined_stem.      0400
  639. combined_stem.0     0218<  0256   0445   0446<
  640. combined_stem.c     0447<
  641. combined_stem.i     0258
  642. dbl.                0588
  643. dbl.bl              0545<  0573
  644. dbl.br              0546<  0573
  645. dbl.h               0543<  0562   0573
  646. dbl.tl              0547<  0562
  647. dbl.tr              0548<  0562
  648. dbl.v               0544<  0563   0563   0564   0564   0565   0565   0568
  649.                     0568   0569   0570   0572   0572
  650. directory           0221<  0222   0402<  0410   0421   0425
  651. drive_letter_colon  0408<  0413<  0419   0425
  652. duration            0474<  0478
  653. elapsed_time        0466<  0467
  654. eoj_rc              0462<  0464<  0479
  655. exe_name            0316<  0322<  0329
  656. existing_inf_hlp_table.
  657.                     0126<  0370
  658. existing_inf_hlp_table.PARAMETER_VALUE
  659.                     0202<
  660. existing_inf_hlp_table.INF_HLP_PATH_AND_FILE_NAME
  661.                     0270
  662. existing_inf_hlp_table.FULL_PATHED_NAME
  663.                     0385<
  664. fn_fext             0372<  0381
  665. full_pathed_name    0384<
  666. hh                  0473<  0474
  667. hlp_folder_class    0229<  0236
  668. hlp_folder_location
  669.                     0228<  0238
  670. hlp_folder_setup    0231<  0239
  671. hlp_folder_title    0230<  0234   0237   0246
  672. hlp_location        0246<  0254   0317   0356   0358
  673. hold_area           0287<  0288
  674. i                   0128   0137   0158   0202   0256   0272   0285
  675. implied_file_extension
  676.                     0146<  0150<  0154<  0178
  677. inf_hlp_area        0279<  0282   0287
  678. inf_hlp_attr        0262
  679. inf_hlp_date        0259
  680. inf_hlp_path_and_file_name
  681.                     0263   0264<  0264   0278   0279   0280   0308   0314
  682.                     0330
  683. inf_hlp_size        0261
  684. inf_hlp_time        0260
  685. inf_hlp_title       0289   0297<  0298   0301   0303<  0304   0306<  0307
  686.                     0324   0335   0337   0343
  687. inf_location        0247<  0254   0323   0356   0357
  688. info_object_id      0113<  0115   0116   0119
  689. info_stem.0         0128
  690. info_stem.i         0133   0136
  691. location            0317<  0323<  0338
  692. lowercase           0101<  0309
  693. micro_seconds       0467   0468
  694. minutes             0471<  0472   0473
  695. mm                  0472<  0473   0474
  696. new_object_count    0255<  0334<  0334   0352   0355
  697. object_id           0318<  0324<  0331
  698. p                   0090<  0091<  0091   0092<  0092   0093<  0093   0094<
  699.                     0094   0095<  0095   0096   0374   0409   0415
  700. parameter_fext      0172   0174   0180   0183<  0184   0186
  701. parameter_fn        0170   0186
  702. parameter_path      0197<  0200
  703. parameter_value     0167   0169   0177<  0178   0185<  0198   0199   0206
  704.                     0207
  705. path_names          0375<  0376   0377   0380
  706. program_name        0476<  0477
  707. ptr                 0410<  0411   0414
  708. remove_characters   0296<  0299   0300
  709. seconds             0467   0469<  0469   0470   0471
  710. setup               0145
  711. setup_string        0326<  0339
  712. ss                  0470<  0471   0474
  713. t                   0428   0442   0500   0502   0576
  714. temp_attr           0433
  715. temp_date           0430
  716. temp_file_extension
  717.                     0437<  0438   0440
  718. temp_path_and_file_name
  719.                     0434   0435<  0435   0437
  720. temp_size           0432
  721. temp_stem.0         0382   0428
  722. temp_stem.1         0384
  723. temp_stem.t         0429   0447
  724. temp_time           0431
  725. token               0378   0381
  726. trap.dul            0550<  0562   0563   0564   0565   0568   0570   0572
  727.                     0573   0574   0575   0577   0579
  728. trap.line_nbr       0497<  0501   0503<  0503
  729. trap.red            0549<  0562   0563   0564   0565   0568   0569   0572
  730.                     0573   0574   0575   0577   0579
  731. trap.width          0561<  0562   0563   0564   0565   0568   0570   0572
  732.                     0573   0574   0575   0577   0579
  733. trap_error_description
  734.                     0553<  0559<  0559   0561   0565
  735. trap_file_name      0520<  0529<  0533<  0535   0537<  0566   0569   0584
  736.                     0586   0589
  737. trap_source_line.0  0502<  0515<  0576
  738. trap_source_line.1  0514<
  739. trap_source_line.t  0501<  0504   0577
  740. uppercase           0102<  0309
  741. uppercase_setup     0145<  0148   0152   0165
  742. view_path_and_file_name
  743.                     0104<  0322
  744. viewhelp_path_and_file_name
  745.                     0106<  0316
  746. w                   0220   0221
  747. with                0165   0169   0258   0288   0377   0429   0467   0518
  748. x                   0290   0543   0544   0545   0546   0547   0548   0549
  749.                     0550
  750.  
  751. ---- LABELS ----
  752. ADD_FULL_PATHED_INF_HLP_TO_ASSOCIATIVE_ARRAY
  753.                     0207   0368:
  754. ADD_HLP_INF_FILES_TO_COMBINED_STEM
  755.                     0222   0398:
  756. EOJ                 0120   0361   0457:
  757. ERROR               0069   0488:
  758. FAILURE             0070   0489:
  759. HALT                0071   0490:
  760. NOVALUE             0072   0491:
  761. RxFuncAdd           0054   0061
  762. SYNTAX              0073   0492:
  763. SysLoadFuncs        0055
  764. SysOpenObject       0357   0358
  765. TRAP_PROCESSING     0488   0489   0490   0491   0492   0495:
  766. WPToolsFolderContent
  767.                     0116
  768. WPToolsLoadFuncs    0062
  769. WPToolsQueryObject  0133
  770.  
  771. ---- FUNCTIONS ----
  772. ARG                 0372   0402   0461   0464   0497   0527   0554   0556
  773.                     0558   0560
  774. CENTER              0564   0565   0569
  775. CHARIN              0279
  776. COPIES              0206   0299   0335   0354   0562   0563   0568   0572
  777.                     0573   0574   0579
  778. DIRECTORY           0512
  779. FILESPEC            0038   0039   0040   0169   0198   0199   0476   0518
  780.                     0520   0521
  781. FORMAT              0470   0472   0473
  782. LEFT                0036   0282   0468   0575   0577
  783. LENGTH              0299   0561
  784. MAX                 0561
  785. POS                 0148   0152   0410   0498   0535
  786. RIGHT               0314   0437   0504
  787. RxFuncQuery         0052   0059   0098   0531
  788. SOURCELINE          0501
  789. SPACE               0298
  790. STREAM              0278   0280
  791. STRIP               0038   0039   0264   0435   0512
  792. SUBSTR              0287   0414
  793. SysCreateObject     0236   0336
  794. SysFileDelete       0586
  795. SysFileTree         0381   0425
  796. SysIni              0099
  797. SysSearchPath       0105   0107
  798. TIME                0045   0046   0466   0477
  799. TRACE               0482
  800. TRANSLATE           0091   0092   0093   0094   0095   0145   0298   0308
  801.                     0384   0476   0478
  802. VALUE               0036   0091   0092   0093   0094   0095   0482
  803. VARDUMP             0589
  804. WORD                0184   0221
  805. WORDS               0180   0220
  806.  
  807. \*-------------------  End of REXX Cross Reference  -------------------*/
  808.