home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / wptool32.zip / WPTOOL.ZIP / GETSET.CMD < prev    next >
OS/2 REXX Batch file  |  1998-09-02  |  4KB  |  138 lines

  1. /* This is a REXX program 
  2.  
  3. A sample REXX file to query settings for objects using the functions
  4. in WPTOOLS.DLL.
  5. */
  6.  
  7.  
  8. Parse arg tCmdLine
  9.  
  10. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  11. rc = SysLoadFuncs()
  12.  
  13. call RxFuncAdd 'WPToolsLoadFuncs', 'WPTOOLS', 'WPToolsLoadFuncs' 
  14. rc = WPToolsLoadFuncs()
  15.  
  16. szObjectName = ""
  17. szParms = ""
  18. do i = 1 to words(tCmdLine)
  19.   tWord = word(tCmdLine, i)
  20.   select
  21.     when TRANSLATE(tWord) = '/S' | TRANSLATE(tWord) = '-S' then do
  22.       szParms = '/S'
  23.       iterate
  24.     end
  25.     otherwise do
  26.       if szObjectName = "" then 
  27.         szObjectName = tWord
  28.       else
  29.         szObjectName = szObjectName || ' ' || tWord
  30.       iterate
  31.       end
  32.    end
  33. end
  34.  
  35. if szObjectName = "" then do
  36.    say 'USAGE: GETSET OBJECTID|PATHNAME [/S]'
  37.    say ''
  38.    say 'Use OBJECTID without < and >'
  39.    say '/S - Also look in subdirs'
  40.    exit
  41. end
  42.  
  43. call SysFileTree szObjectName, 'rgFiles', 'O'
  44. if rgFiles.0 > 0 then do
  45.   do i = 1 to rgFiles.0
  46.       call GetSettings rgFiles.i, szParms
  47.   end
  48.   if szParms = '/S' Then Do
  49.     szObjectName = szObjectName || '\*.*'
  50.     call SysFileTree szObjectName, 'rgFiles', 'OS'
  51.     if rgFiles.0 > 0 then do
  52.       do i = 1 to rgFiles.0
  53.         call GetSettings rgFiles.i, szParms
  54.       end
  55.     end
  56.   end
  57.   exit
  58. end
  59.  
  60.  
  61. szObjectName = '<' || szObjectName || '>'
  62. call GetSettings szObjectName, szParms
  63.  
  64. Exit
  65.  
  66. /***********************************************************************
  67. * GetSettings
  68. ***********************************************************************/
  69. GetSettings:
  70. iRetco = WPToolsQueryObject(ARG(1), "szClass", "szTitle", "szSetupString", "szLocation") 
  71. if iRetco Then do
  72.      Call WriteObject szClass, szTitle, szSetupString, szLocation
  73.   end 
  74. else
  75.   say 'Unable to return object settings for ' ARG(1)
  76.  
  77. if ARG(2) = '/S' Then Do
  78.  
  79. iRetco = WPToolsFolderContent(ARG(1), "list.")
  80. if iRetco = 0 Then Do
  81.    Say 'WPToolsFolderContent for 'ARG(1)' returned 0'
  82.    return
  83. End
  84.  
  85. do iObject = 1 to list.0
  86.   iRetco=WPToolsQueryObject(list.iObject, "szClass", "szTitle", "szSetupString", "szLocation") 
  87.   if iRetco Then do
  88.      Call WriteObject szClass, szTitle, szSetupString, szLocation
  89.   end 
  90. end
  91. End
  92. return
  93.  
  94. /***********************************************************************
  95. * WriteObject
  96. ***********************************************************************/
  97. WriteObject:
  98. Parse Arg szClass, szTitle, szSetupString, szLocation
  99.  
  100. /* To find Windows progs with SET's.
  101.    Something you should not want, since then the defaults
  102.    from the WIN-OS/2 setup are NOT used.
  103.  
  104.    if POS('PROG_31_', szSetupString) = 0 Then Return
  105.    if POS('SET ', szSetupString) = 0 Then Return
  106. */
  107.  
  108.    Say 'OBJECT "'szClass'" "'szTitle'" "'szLocation'"'
  109.  
  110.    bQuote = '"'
  111.    iStart = 1
  112.    Do While Length(szSetupString) > 0
  113.         iEnd = POS(';', szSetupString, iStart) 
  114.         if iEnd = 0 Then Leave
  115.         iQuote = 0 /* POS('"', szSetupString, iStart) */
  116.         if iQuote = 0 | iQuote > iEnd Then Do
  117.            szValue = SubStr(szSetupString, 1, iEnd)
  118.            szSetupString = SubStr(szSetupString, iEnd + 1)
  119.            If Length(szSetupString) = 0 Then
  120.               Say '       'bQuote||szValue'"'
  121.            Else
  122.               Say '       'bQuote||szValue
  123.            iStart = 1
  124.            bQuote = ' '
  125.            End 
  126.         else Do
  127.            iStart = iEnd + 1
  128.            End
  129.    end
  130.  
  131.    if Length(szSetupString) > 0 Then Do
  132.      Say '     ' szSetupString'"'
  133.    End
  134.    Say ' '
  135.         
  136.  
  137. Return
  138.