home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / wps / utils / allinfs / allinfs.cmd next >
Encoding:
Text File  |  1993-01-17  |  5.4 KB  |  200 lines

  1. /* ALLINFS.CMD    by Leshek Fiedorowicz 1992-11-15                */
  2. /* To create VIEW folder with all your .INF files                 */
  3.  
  4. Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  5. Call SysLoadFuncs
  6.  
  7. listfile = 'AllInfs.lst'
  8. IconFile = 'AllInfs.ico'
  9.  
  10. say
  11. say 'AllInfs - by Leshek Fiedorowicz; CIS#74170,2007'
  12. say
  13. say 'Searching your drives for *.INF files.  Please wait... '
  14. Call CSeeAll;
  15. say
  16.  
  17. if lines(listfile) = 0 then
  18. do;
  19.    say
  20.    say '*** Warning: AllInfs list file not found, object will have names same'
  21.    say '             as files names.  Do you want to continue (Y/anything) ?'
  22.    pull ans
  23.    if strip(ans) \= 'Y' then do;
  24.       say '    Place AllInfs.LST in current directory and try again.'
  25.       say '    Thank you for using AllInfs .... Leshek Fiedorowicz.'
  26.       say
  27.       exit 4;
  28.    end;
  29. end;
  30.  
  31. /* read list file */
  32. cnt = 0;
  33. list. = '';
  34. do while lines(listfile);         /* Read input file */
  35.    cnt = cnt + 1;
  36.    list.cnt = linein(listfile);
  37. end;
  38. list.0 = cnt;
  39.  
  40. icf. = '';
  41. /* Find icon file (first occurence on the current drive           */
  42. rc = SysFileTree('\'IconFile, 'icf', 'SF')
  43. parse var icf.1 date time size attribs IconFileFullName;
  44. IconFileFullName = Strip(IconFileFullName );
  45.  
  46. /* Create Foler on the Desktop                                    */
  47. classname = 'WPFolder';
  48. title = 'All IPFs';
  49. location = '<WP_DESKTOP>';
  50. setup='OBJECTID=<All_IPFs>;'||,
  51.       'ICONVIEW=FLOWED;'||,
  52.       'ICONFILE='IconFileFullName;
  53.       /* SORT= LE=filename */
  54. rc = SysCreateObject(classname, title, location, setup);
  55. if rc \= 1 then do;
  56.    say 'Unable to create <All IPFs> Folder, it may already exist.';
  57.    say 'Processing Continues ... new IPFs will be added ... ';
  58.    Say
  59. end;
  60.  
  61. errors = '';
  62. errors.0 = 0;
  63.  
  64. say 'In the following display:'
  65. say '   . found file with .INF extension but not in a VIEW format.';
  66. say '   - found file with .INF but unable to create corresponding object.';
  67. say '   + found file with .INF and succesfully created object.';
  68. Say 'Please wait...';
  69.  
  70. count = 0;
  71. /* Main processing loop */
  72. do in = 1 to AllFile.0;
  73.    /* rc= charout(,'.'); */
  74.    parse var AllFile.in date time size attribs infile'.'ext;
  75.    InFile = Strip(InFile);
  76.    LastBSlashPos = Lastpos('\', Infile);
  77.    InfPath = Substr(InFile, 1, LastBSlashPos);
  78.    InFile = Substr(InFile, (LastBSlashPos + 1));
  79.    object = infpath||infile||'.INF';
  80.    firstline = linein(object,1,1);
  81.    call Stream object, 'c', 'close';
  82.    if substr(firstline,1,4) \= 'HSP'||'01'x then do;
  83.       rc= charout(,'.');
  84.       iterate;                  /* Ignore non VIEWable files              */
  85.    end;
  86.    title = infile infpath;
  87.    infile = translate(infile)   /* Uppercase file name                    */
  88.    do k = 1 to list.0
  89.       parse var list.k fl ttl
  90.       if fl = infile then do;
  91.          title = strip(ttl);
  92.          leave k;
  93.       end;
  94.    end;
  95.    if title = 'EXCLUDE' then
  96.       iterate;                  /* Ignore specified files                 */
  97.  
  98.    ClassName = 'WPProgram';
  99.    /* Title = Title;                                                      */
  100.    Location = '<All_IPFs>';
  101.    Setup = 'PROGTYPE=PM;'||,
  102.            'EXENAME=VIEW.EXE;'||,
  103.            'PARAMETERS='object';'||,
  104.            'OBJECTID=<'object'>;';
  105.    rc = SysCreateObject(ClassName, Title, Location, Setup);
  106.  
  107.    if rc = 1 then do;
  108.       rc= charout(,'+');
  109.       count = count + 1;
  110.    end;
  111.    else do;
  112.       rc= charout(,'-');
  113.       errors.0 = errors.0 + 1;
  114.       i = errors.0;
  115.       errors.i = object;
  116.    end;
  117. end;
  118.  
  119. say
  120.  
  121. if errors.0 \= 0 then do;
  122.    say
  123.    if error.0 >1 then
  124.       txt = 'files have'
  125.    else
  126.       txt = 'file has'
  127.  
  128.    say '*** The following 'txt' not been processed correctly (may already exist):'
  129.    ns = 22;
  130.    done = 0;
  131.    do i = 1 to errors.0
  132.       if ((i - done) //ns = 0) then do;
  133.          Say 'Press any key to continue...';
  134.          Pull;
  135.          done = (i - done) + done;
  136.          ns = 22;
  137.       End;
  138.       tx = right(i,7)': 'errors.i
  139.       say tx
  140.       If length(tx) > 80 then
  141.          ns = ns -1;
  142.    end;
  143. end;
  144.  
  145. say
  146. select
  147.   when count = 0 then
  148.        say 'No objects created.'
  149.   when count = 1 then
  150.        say 'One .INF object has been created in <All IPFs> folder on your desktop.';
  151.   Otherwise
  152.        say count' INF objects have been created in <All IPFs> folder on your desktop.';
  153. end;
  154.  
  155. say 'Thank you for using AllInfs .... Leshek Fiedorowicz.'
  156. say
  157.  
  158. exit 0;
  159.  
  160. /* SEEALL     - by Leshek Fiedorowicz                             */
  161. /* To find all file occurences on any drive, using wildcard       */
  162. CSeeAll:
  163.  
  164. file = '*.INF'
  165.  
  166. /* Find all logical drives available - onto Drive. stem           */
  167. AllDrives = SysDriveMap('c:', 'USED');
  168. Drive. = '';
  169. cnt = 0;
  170. Do While AllDrives \= ''
  171.    cnt = cnt + 1;
  172.    Parse var AllDrives Drive.cnt AllDrives
  173. End;
  174. Drive.0 = cnt;
  175.  
  176. if Drive.0 = 0 then do;
  177.    say 'Error : no logical drives found !'
  178.    Exit 8;
  179. End;
  180.  
  181. /* Check for the file on all available logical drives             */
  182. AllFile. = '';
  183. AllCnt = 0;
  184. Do d = 1 to Drive.0;
  185.    c1=Substr(Drive.d,1,1); c2=Substr(Drive.d,2,1);
  186.    rc= charout(,c1); rc= charout(,c2); rc= charout(,'  ');
  187.    rc = SysFileTree(Drive.d'\'file, 'file', 'SF')
  188.    If rc \= 0 then say 'ERROR in SysFileTree call - 'rc
  189.    do i=1 to file.0
  190.       AllCnt = AllCnt + 1;
  191.       AllFile.AllCnt = file.i
  192.    End;
  193. End;
  194. AllFile.0 = AllCnt;
  195. rc= charout(,'0A'x);
  196. rc= charout(,'0D'x);
  197.  
  198. Return;
  199.  
  200.