home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / getset.zip / GET_ALL1.CMD next >
OS/2 REXX Batch file  |  1994-01-28  |  8KB  |  219 lines

  1. /**** REXX Prog to Get ALL User Settings  GET_ALL1.CMD ****/
  2.  
  3. /**********************************************
  4. W. Robert S. Webber
  5. (C) Squarey Software Dec 1993
  6. e-mail internet bwebber@welchlink.welch.jhu.edu
  7. e-mail CompuServe 70154,546
  8. **********************************************/
  9.  
  10. /****
  11. Data concepts:
  12. An .INI file is a list of APPs ( also = sections )
  13.     An APP has an APP_NAME and is a list of KEYs
  14.         A KEY has a KEY_NAME and is a string of bytes, ends with 0.
  15.             (This program processes a KEY into a list or WORDs by
  16.                 replacing non printing chars with space. Multi space
  17.                 is then replaced with single space)
  18.         A KEY has a KEY_NAME and is an array of WORDs.
  19.             
  20. GET_ALL1 will list out all items in the USER file OS2.INI.
  21. There are two optional arguments Name and Mask that can be
  22. used to restrict the output. If both arguments are omitted, then all
  23. items are listed.
  24.  
  25. If Name is given only items containing WORDs that match Name will be listed.
  26.  
  27. APP ( sections ) names are still listed even if none of the KEYs contain
  28. any WORDs that match Name. In this case the number of KEYs skipped is shown
  29.  
  30. Name need not be the full name, but can be fewer characters starting at
  31. the begining of the item name.
  32. If less than the full name is given all items matching the reduced name
  33. will be listed, i.e. if Name is MY, then MY_Prog and MYGAME will both be
  34. listed but not NEW_MY_GAME. The match always starts at the begining of the word.
  35.  
  36. Names with spaces will be listed on spearate lines in the output 
  37. and cannot be specified in full. In this case just use the first
  38. word of the item name, or change the spaces to underscores.
  39. Name is not the .EXE name but the name as it appears on the
  40. Desktop under the icon. Name is case insensitive, i.e. MyProg=myprog=MYPROG.
  41.  
  42. Mask is another optional parameter that can be used to further restrict
  43. output. If Mask is given only items containing WORDs that match
  44. Mask will be listed.
  45.  
  46. Mask can be used to match the class or attribute of the object.
  47. If given then all items listed will contain WORDs matching both Name and Mask.
  48. As with Name, Mask can be shorter than the full name of the object and
  49. is also case insensitive.
  50.  
  51. If either Name or Mask are used, then they must be at least 3 letters long.
  52.  
  53. For DOS Session Settings:
  54. It appears that OS2.INI only contains differences from default, so that only
  55. those settings that are no set to their default value will be listed. As a
  56. consequence, this program does not produce a full list of the DOS settings
  57. for a given program.
  58.  
  59. Usage:
  60. get_all1 Name Mask
  61. where Name and Mask are optional and case insensitive. This will list
  62. all items matching Name and Mask to the screen.
  63. If output to a file is required, then redirect to a file as:
  64. get_all1 Name Mask >my_set.lst
  65.  
  66. Examples:
  67. To lsit all items to the screen:
  68. get_all1
  69.  
  70. To list all iems to a file:
  71. get_all1 >my_progs.lst
  72.  
  73. To list all MYGAME items to a file:
  74. get_all1 MYGAME >my_games.lst
  75.  
  76. To list all utils but only their shadows
  77. get_all1 UTil wpsh >my_shad.lst
  78.  
  79. This example assumses all util item names start with util.
  80. The irregular case will be ignored. Mask uses a short word "wpsh" for
  81. WPShadow to select only shodow programs, again case is ignored.
  82.  
  83. If you just want to work with program objects e.g. DOS Sessions
  84. use GET_SET1.CMD
  85. ****/
  86.  
  87. /**** Add Extra functions to REXX ****/
  88. call RXFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs'
  89. call SysLoadFuncs
  90.  
  91. parse arg Look Mask
  92.  
  93. Look = strip( Look )        /* Remove any extra lead/trail spaces */
  94. Look = translate( Look )    /* Force all to UPPER case */
  95. LookLen = length( Look )
  96.  
  97. Mask = strip( Mask )
  98. Mask = translate( Mask )
  99. MaskLen = length( Mask )
  100.  
  101. MinKey = 3  /* Length of smallest Word in key to be printed */
  102. FieldWidth = 25 /* Max name Field width */
  103.  
  104. say "Input: Name Size    " Look LookLen Mask MaskLen
  105. say "Smallest Key Word = " MinKey
  106. say "Name Field width  = " FieldWidth
  107.  
  108. tab1 = "   "   /* Space out for Key Lines */
  109. tab2 = tab1 || tab1
  110. tab3 = tab2 || tab1
  111.  
  112. /***** Range of chars to be change to space.
  113. i.e. all non ASCII chars *****/
  114. SpaceMask = xrange( '00'x, '09'x ) || xrange( '0B'x, '1F'x ) ||,
  115.     xrange( '7F'x, 'FF'x )
  116.  
  117. say "## Scanning OS2.INI "
  118. call SysIni 'USER', 'All:', 'Apps.'
  119. if Result \= 'ERROR:' then do
  120.  
  121.     say "USER OS2.INI has " Apps.0 "Sections"
  122.         /**** Apps is an array of APP_NAMEs ****/
  123.  
  124. /*** Scan Sections ****/
  125.     do ii = 1 to Apps.0
  126.     
  127.         call SysIni 'USER', Apps.ii, 'All:', 'Keys.'
  128.             /**** Keys is an array of KEY_NAMEs ****/
  129.  
  130.         if Result \= 'ERROR:' then do
  131.             say
  132.             say substr( Apps.ii, 1, FieldWidth ) "== " Keys.0 "Keys"
  133.  
  134. /**** Scan Keys in sections ****/
  135.             SkipKey = 0
  136.             do j = 1 to Keys.0
  137.                 val = SysIni( 'USER', Apps.ii, Keys.j )
  138.                     /*** val is a KEY_FIELD ***/
  139.  
  140. /**** Replaced NL, CR with something ****/
  141. /*                 val2 = translate( val, "~~", '0A'x || '0D'x, ' ' ) */
  142.                 val2 = translate( val, "  ", '0A'x || '0D'x, ' ' )
  143.  
  144.  
  145. /**** Set non ACSII to space ****/
  146.                 val = translate( val2, ' ', SpaceMask, ' ' )
  147.  
  148.                 val2 = space( val ) /* remove all extra space */
  149.                 val = val2
  150.  
  151.                 Nwval = words( val )   /* Get number of words now in Key */
  152.  
  153. /**** See if any of the words in the current key match
  154. what we are looking. Default is to print all if no string given, or
  155. too short ****/
  156.                 if LookLen > 2 then do
  157.                     FoundProg = "NO"
  158.                     do k = 1 to Nwval
  159.                         val3 = word( val, k )
  160.                         if translate( left( val3, LookLen ) ) = Look then,
  161.                             FoundProg = "YES"
  162.                         end /* do k */
  163.  
  164.                     end /* if LookLen */
  165.  
  166.                 else FoundProg = "YES"
  167.  
  168.                 if ( MaskLen > 2 ) & ( FoundProg = "YES" ) then do
  169.                     FoundProg = "NO"
  170.                     do k = 1 to Nwval
  171.                         val3 = word( val, k )
  172.                         if translate( left( val3, MaskLen ) ) = Mask then,
  173.                             FoundProg = "YES"
  174.                         end  /* do k */
  175.                     end /* if MaskLen */
  176.  
  177.                 if FoundProg = "YES" then do
  178.                     /* say */
  179.                     say tab1 substr( Keys.j, 1, FieldWidth ),
  180.                         Nwval "words Len" length(val)
  181.                     
  182.                     ShortCnt = 0
  183.  
  184.                     do k = 1 to Nwval
  185.                         val2 = word( val, k )
  186.  
  187. /**** Skip short words ****/
  188.                         if ( length( val2 ) > ( MinKey - 1 ) ) then
  189.                             say tab2 word( val, k )
  190.                         else ShortCnt = ShortCnt + 1
  191.  
  192.                         end /* do k */
  193.  
  194.                     if  ShortCnt > 0 then
  195.                         say tab3 "Note: " ShortCnt "Words < " MinKey "Skipped"
  196.  
  197.                     end /* if FoundProg */
  198.  
  199.                 else SkipKey = SkipKey + 1
  200.         
  201.                 end /* do j */
  202.  
  203.             if SkipKey > 0 then
  204.                 say tab1 "Section " Apps.ii SkipKey "Keys Skipped"
  205.  
  206.             end /* if Result */
  207.  
  208.         else do
  209.             say "SysIni " Result Apps.ii
  210.             end  /* do */
  211.  
  212.         end /* do ii */
  213.  
  214.     end /* if Result */
  215.  
  216. else do
  217.     say "SysIni " Result
  218.     end
  219.