home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / getset.zip / GET_SET1.CMD < prev   
OS/2 REXX Batch file  |  1994-01-28  |  6KB  |  185 lines

  1. /**** REXX Prog to Get Program Settings  GET_SET1.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. GET_SET1 will list out the setting for all Porgrams in the USER
  12. file OS2.INI, i.e. all PM_Abstract:Objects. There are two optional arguments
  13. Name and Mask that can be used to restrict the output. If both arguments are
  14. omitted, then all programs are listed.
  15.  
  16. If Name is given only programs matching Name will be listed.
  17.  
  18. Name need not be the full name, but can be fewer characters starting at
  19. the begining of the program name.
  20. If less than the full name is given all programs matching the reduced name
  21. will be listed, i.e. if Name is MY, then MY_Prog and MYGAME will both be
  22. listed but not NEW_MY_GAME. The match always starts at the begining of the word.
  23.  
  24. Names with spaces will be listed on spearate lines in the output 
  25. and cannot be specified in full. In this case just use the first
  26. word of the program name, or change the spaces to underscores.
  27. Name is not the .EXE name but the name as it appears on the
  28. Desktop under the icon. Name is case insensitive, i.e. MyProg=myprog=MYPROG.
  29.  
  30. Mask is another optional parameter that can be used to further restrict
  31. output. Mask can be used to match the class or attribute of the object.
  32. If given then all programs listed will match both Name and Mask.
  33. As with Name, Mask can be shorter than the full name of the object and
  34. is also case insensitive.
  35.  
  36. If either Name or Mask are used, then they must be at least 3 letters long.
  37.  
  38. It appears that OS2.INI only contains differences from default, so that only
  39. those settings that are no set to their default value will be listed. As a
  40. consequence, this program does not produce a full list of the DOS settings
  41. for a given program.
  42.  
  43. Usage:
  44. get_set1 Name Mask
  45. where Name and Mask are optional and case insensitive. This will list
  46. all programs matching Name and Mask to the screen.
  47. If output to a file is required, then redirect to a file as:
  48. get_set1 Name Mask >my_set.lst
  49.  
  50. Examples:
  51. To lsit all programs to the screen:
  52. get_set1
  53.  
  54. To list all programs to a file:
  55. get_set1 >my_progs.lst
  56.  
  57. To list all MYGAME programs to a file:
  58. get_set1 MYGAME >my_games.lst
  59.  
  60. To list all utils but only their shadows
  61. get_set1 UTil wpsh >my_shad.lst
  62.  
  63. This example assumses all util program names start with util.
  64. The irregular case will be ignored. Mask uses a short word "wpsh" for
  65. WPShadow to select only shodow programs, again case is ignored.
  66.  
  67. If you want to work with all objects use GET_ALL1.CMD
  68. ****/
  69.  
  70. /**** Add Extra functions to REXX ****/
  71. call RXFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs'
  72. call SysLoadFuncs
  73.  
  74.  
  75. /**** Set up preferences ****/
  76. NewLine = "  "  /* How NL, CR are to be treated */
  77.  
  78. tab1 = "    "   /* Tab width in spaces */
  79. tab2 = tab1 || tab1
  80.  
  81. SearchObj = "PM_Abstract:Objects"   /* Select program Objects */
  82. MinKey = 3  /* Length of smallest Word in key to be printed */
  83.             /* Keys smaller than this will be skipped */
  84.  
  85. /***** Range of chars to be change to space.
  86. i.e. all non ASCII chars *****/
  87. SpaceMask = xrange( '00'x, '09'x ) || xrange( '0B'x, '1F'x ) ||,
  88.     xrange( '7F'x, 'FF'x )
  89.  
  90.  
  91. parse arg Look Mask         /* Get input form command line */
  92.  
  93. Look = strip( Look )        /* Remove any extra lead/trail spaces */
  94. Look = translate( Look )    /* Set to all Upper case */
  95. LookLen = length( Look )
  96.  
  97. Mask = strip( Mask )
  98. Mask = translate( Mask )
  99. MaskLen = length( Mask )
  100.  
  101. /**** Log what we are doing ****/
  102. say "Input: Name=" Look LookLen "Mask=" Mask MaskLen
  103. say "Search Class " SearchObj "Smallest Key Word= " MinKey
  104.  
  105. /**** Get list of all program object keys ****/
  106. call SysIni 'USER', SearchObj, 'All:', 'Keys.'
  107.  
  108. if (Result \= 'ERROR:') then do
  109.  
  110.      say SearchObj "Has " Keys.0 "Keys"
  111.      SkipKey = 0
  112.  
  113.      do j = 1 to Keys.0
  114.          val = SysIni( 'USER', SearchObj, Keys.j )
  115.  
  116. /**** Need to get rid of all non printing characters by changing then to space.
  117. Replaced NL, CR with something. These are treated separately first
  118. so that Nl & CR can be made to show up with a special char pair if need be
  119. ****/
  120.          val2 = translate( val, NewLine, '0A'x || '0D'x, ' ' )
  121.  
  122.  
  123. /**** Set non ACSII to space ****/
  124.          val = translate( val2, ' ', SpaceMask, ' ' )
  125.  
  126.          val2 = space( val ) /* remove all extra space */
  127.          val = val2
  128.  
  129.          Nwval = words( val )   /* Get number of words now in Key */
  130.  
  131. /**** See if any of the words in the current key match
  132. what we are looking. Default is to print all if no string given, or
  133. too short ****/
  134.          if LookLen > 2 then do
  135.              FoundProg = "NO"
  136.              do k = 1 to Nwval
  137.                 val3 = word( val, k )
  138.                 if translate( left( val3, LookLen ) ) = Look then,
  139.                     FoundProg = "YES"
  140.                 end /* do k */
  141.  
  142.              end /* if LookLen */
  143.  
  144.          else FoundProg = "YES"
  145.  
  146.          if ( MaskLen > 2 ) & ( FoundProg = "YES" ) then do
  147.              FoundProg = "NO"
  148.              do k = 1 to Nwval
  149.                 val3 = word( val, k )
  150.                 if translate( left( val3, MaskLen ) ) = Mask then,
  151.                     FoundProg = "YES"
  152.                 end  /* do k */
  153.              end /* if MaskLen */
  154.  
  155.          if FoundProg = "YES" then do
  156.             say
  157.             say substr( Keys.j, 1 ,30)  j "has " Nwval "words Len=" length(val)
  158.             
  159.             ShortCnt = 0
  160.  
  161.             do k = 1 to Nwval
  162.                 val2 = word( val, k )
  163.  
  164. /**** Skip short words ****/
  165.                 if ( length( val2 ) > ( MinKey - 1 ) ) then
  166.                     say tab1 word( val, k )
  167.                 else ShortCnt = ShortCnt + 1
  168.                 
  169.                 end /* do k */
  170.             say tab2 "Note: " ShortCnt "Words less than " MinKey "Skipped"
  171.             end /* if FoundProg */
  172.  
  173.          else SkipKey = SkipKey + 1
  174.  
  175.          end /* do j */
  176.     say
  177.     say "-----------------------------"
  178.     say Keys.0 - SkipKey "Porgrams Listed" SkipKey "Object Keys Skipped"
  179.  
  180.     end /* if Result */
  181.  
  182. else do
  183.     say "Error Reading " SearchObj Look Mask
  184.     end
  185.