home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / greed223.zip / ApplSet.CMD next >
OS/2 REXX Batch file  |  1997-12-06  |  6KB  |  171 lines

  1. /* REXX **********************************************/
  2. /*                                                   */
  3. /* Program name: ApplSet                             */
  4. /*                                                   */
  5. /* Function....:                                     */
  6. /* Author......: Janosch R. Kowalczyk                */
  7. /* Create date.:                                     */
  8. /* Version.....:                                     */
  9. /*                                                   */
  10. /* Changes:                                          */
  11. /*                                                   */
  12. /* (C) Copyright Janosch R. Kowalczyk, 1996.         */
  13. /* All rights reserved.                              */
  14. /*                                                   */
  15. /*****************************************************/
  16. /* trace r */
  17. Parse Source envir calledAs procName .
  18. Parse Arg destPath 
  19.  
  20. /*===============(Exception handling)================*/
  21. Signal On Failure Name CLEANUP
  22. Signal On Halt    Name CLEANUP
  23. Signal On Syntax  Name CLEANUP
  24.  
  25. Call On NOTREADY
  26.  
  27. /*============(Initialize RexxUtil support)===========*/
  28. If RxFuncQuery('SysLoadFuncs') Then Do
  29.   Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  30.   Call SysLoadFuncs
  31. End /* If RxFuncQuery... */
  32.  
  33. currDir = Directory( destPath ) 
  34.  
  35. /*------------(Get data value for a key)------------*/
  36. inifile = destPath'\GreedX.fnc'  /* USER SYSTEM BOTH Pathname */
  37. appl    = 'Constructs' /* Application name          */
  38. key     = 'Rexx frame' /* Key name                  */
  39. value = SysIni( inifile, appl, key )
  40. If value = 'ERROR:' Then Do
  41.   /* Say 'File' inifile 'will be restructured' */
  42.   Call CopyAppl inifile, inifile
  43.   /* Say Copies( '=', 60 ) */
  44. End
  45. Else delFlag = 1
  46.  
  47. /*------------(Get data value for a key)------------*/
  48. inifile = 'Greed.fnc'  /* USER SYSTEM BOTH Pathname */
  49. appl    = 'Constructs' /* Application name          */
  50. key     = 'Rexx frame' /* Key name                  */
  51. value = SysIni( inifile, appl, key )
  52. If value = 'ERROR:' Then Do
  53.   /* Say 'Now the file' inifile */
  54.   Call CopyAppl inifile, inifile
  55. End
  56. Else If delFlag = 1 Then Do
  57.   delRC = SysFileDelete( 'CAPPLOG.grd' )
  58. End
  59.  
  60. /*=================(End this program)=================*/
  61. Exit
  62.  
  63. CLEANUP:
  64.   Say 'GREED001E - Break, Failure or Syntax Error'
  65.   Say 'GREED002E - in the procedure' pgmName'.' 
  66. Exit
  67.  
  68. NOTREADY:
  69.   Parse Var response . ':' errcode
  70.   If DataType( errcode ) = 'NUM' Then
  71.     Say SysGetMessage(errcode)
  72.   Say
  73.   Call LineOut ,"Retry (Y/N)? "
  74.   Pull response
  75.   If response = 'N' Then Exit
  76.  
  77. Return
  78.  
  79.  
  80. /*=================(P R O C E D U R E S)=================*/
  81.  
  82. CopyAppl: Procedure Expose pgmName
  83. Arg iniFile, iniDest  
  84.  
  85. fileName = 'CAPPLOG.grd'
  86. /*-----------(Get names of all applications)----------*/
  87. result = SysIni( iniFile, 'ALL:', 'appl' )
  88. If result = 'ERROR:' | appl.0 = 0 Then 
  89.   /* Say result 'No application(s) found' */
  90. Else Do
  91.   Do i = 1 To appl.0
  92.     Say appl.i
  93.     outLine = 'inAppl.'i '= "'appl.i'"'
  94.     rc = LineOut( fileName, outLine )
  95.     appl = appl.i                /* Application name */
  96.     result = SysIni( iniFile, appl, 'ALL:', 'key' )
  97.     If result = 'ERROR:' | key.0 = 0 Then
  98.       Say result 'No key(s) found for application' appl.i
  99.     Else Do
  100.       If appl = 'Rexx Constructs' | appl = 'Constructs' Then
  101.         destAppl = 'Constructs'
  102.       Else If appl = 'Rexx API' | appl = 'API' Then
  103.         destAppl = 'API'
  104.       Else If appl = 'Rexx Built-in Functions' | appl = 'Rexx built-in functions' Then 
  105.         destAppl = 'Rexx built-in functions'
  106.       Else If appl = 'RexxUtil' Then destAppl = appl
  107.       Else destAppl = ''
  108.       If destAppl > '' Then Do
  109.         Do j = 1 To key.0
  110.           outLine = destAppl key.j
  111.           Say outLine
  112.           rc = LineOut( fileName, outLine )
  113.           value = SysIni( iniFile, appl, key.j )
  114.           /* rc = LineOut( fileName, value ) */
  115.           If key.j = 'SysIni: Delete Application' Then Do
  116.             key = 'SysIni: Delete application'
  117.             retVal = SysIni( iniDest, destAppl, key, value )
  118.           End
  119.           Else If key.j = 'SysIni: Delete Key' Then Do
  120.             key = 'SysIni: Delete key'
  121.             retVal = SysIni( iniDest, destAppl, key, value )
  122.           End
  123.           Else If key.j = 'SysIni: Get Data Value' Then Do
  124.             key = 'SysIni: Read value'
  125.             retVal = SysIni( iniDest, destAppl, key, value )
  126.           End
  127.           Else If key.j = 'SysIni: Get Names of all Applications' Then Do
  128.             key = 'SysIni: Read all applications'
  129.             retVal = SysIni( iniDest, destAppl, key, value )
  130.           End
  131.           Else If key.j = 'SysIni: Get Names of all Keys' Then Do
  132.             key = 'SysIni: Read all keys'
  133.             retVal = SysIni( iniDest, destAppl, key, value )
  134.           End
  135.           Else If key.j = 'SysIni: Write Data Value' Then Do
  136.             key = 'SysIni: Write value'
  137.             retVal = SysIni( iniDest, destAppl, key, value )
  138.           End
  139.           Else If key.j = 'Center/Centre' Then Do
  140.             key = 'Center'
  141.             retVal = SysIni( iniDest, destAppl, key, value )
  142.           End
  143.           Else If key.j = 'BitXOr' Then Do
  144.             key = 'BitXor'
  145.             retVal = SysIni( iniDest, destAppl, key, value )
  146.           End
  147.           Else
  148.             retVal = SysIni( iniDest, destAppl, key.j, value )
  149.  
  150.           If retVal > '' Then
  151.             Say 'Error writting/deleting' destAppl',' key
  152.         End
  153.         /* CAUTION: The next code line deletes all moved applications. Don't use */
  154.         /* it if you want to use still Greed Version 2.11 or previous            */ 
  155.         /* If appl \= destAppl Then retVal = SysIni( iniDest, appl, 'DELETE:' )  */
  156.       End
  157.     End
  158.   End
  159.   value = SysIni( iniFile, 'Rexx Frames', 'RexxUtil' )
  160.   if value \= 'ERROR:' Then Do
  161.     retVal = SysIni( iniDest, 'Constructs', 'Rexx frame', value )
  162.     outLine = 'Constructs' 'Rexx frame'
  163.   End 
  164.   Else
  165.     outLine = Value
  166.   Say outLine
  167.   rc = LineOut( fileName, outLine )
  168.   status = Stream( fileName, 'C', 'Close' )
  169. End
  170.  
  171. return 0