home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / DESKUTIL.ZIP / wpsgen.cmd < prev    next >
OS/2 REXX Batch file  |  1992-07-30  |  5KB  |  153 lines

  1. /***+---------------------------------------------------------WPSGEN.CMD
  2.  ********************************************************************
  3.  *                                                                  *
  4.  *           Copyright (c) 1992, Blue Bird Computing, Inc.          *
  5.  *                                                                  *
  6.  *  Permission is granted for this program to be used, copied,      *
  7.  *  modified, and/or redistributed by anyone provided that no fee   *
  8.  *  is charged and this notice and the change log are not removed.  *
  9.  *                                                                  *
  10.  ********************************************************************
  11.  
  12.               WPSGEN - Generate WPS Objects from a Script
  13.  
  14.   This Rexx program will create WPS objects from data in a script file.
  15.   It allows for testing and easily re-doing work on re-installs.  It
  16.   can also be used to easily set up multiple OS/2 workstations with the
  17.   same or similar program groups and entries.
  18.  
  19.   Synopsis:        WPSGEN  <filename>
  20.  
  21.   Returns:         0  - always
  22.  
  23.   Input:           filename  - the name of script file (no default
  24.                                assumption about extension) that
  25.                                contains definitions for objects to
  26.                                be created.
  27.  
  28.   Output:          Messages to the screen
  29.                    Work Place Shell objects are created
  30.  
  31.   Calls:           REXXUTIL.DLL functions:
  32.                       SysLoadFuncs
  33.                       SysCls
  34.                       SysCreateObject
  35.  
  36.   Called by:       People like you and me
  37.  
  38.   Environments:    OS/2 V2.0+
  39.  
  40.   Notes:           Input file has the format:
  41.  
  42.                      Class     classname
  43.                      name      object name
  44.                      location  place to put it
  45.                      Attr      setup string data
  46.                      attr      more setup string data
  47.                      .
  48.                      install
  49.  
  50.                    Case of the keywords is not significant, though
  51.                    case in the data is.
  52.  
  53.                    Comments may be included by prefixing them with
  54.                    an asterisk. Comments and blank lines are ignored.
  55.  
  56.                    Note that setup string elements must be terminated
  57.                    by semicolons.  This program will put in the
  58.                    semicolons after each Attr if needed but if more
  59.                    than one string is give on each attr line, the
  60.                    semicolons must be embedded.
  61.  
  62.   Version history:
  63.    Revision 1.0  12Jun92 M.A. Stern (Blue Bird Computing, Inc.)
  64.     New
  65.  
  66.    Revision 1.1  30Jul92 M.A. Stern (Blue Bird Computing, Inc.)
  67.     Improve internal documentation.
  68. ****------------------------------------------------------------------*/
  69.  
  70. Arg Filename .
  71. If Lines( filename ) < 1 Then Do
  72.    Say 'Input file' Filename 'not found.'
  73.    Exit
  74.    End
  75.  
  76. /* Load REXXUTIL */
  77. call rxfuncadd sysloadfuncs, rexxutil, sysloadfuncs
  78. call sysloadfuncs
  79.  
  80. call SysCls
  81. Say '';Say 'Using REXXUTILs to Create WPS desktop Objects...'
  82.  
  83. Added = 0
  84. Failed = 0
  85.  
  86. Call InitWps
  87.  
  88. Do While Lines( Filename ) > 0
  89.  
  90.    Rec = Strip( Linein( Filename ) )
  91.    if Rec = '' | Left( Rec,1 ) = '*' Then Iterate
  92.    Parse var Rec Keyword Data
  93.    Data = Strip( Data )
  94.    Keyword = Translate( Keyword )
  95.    Select
  96.  
  97.       When Keyword = 'CLASS'    Then WpsClass = Data
  98.       When Keyword = 'NAME'     Then WpsName = Data
  99.       When Keyword = 'LOCATION' Then WpsLoc = Data
  100.  
  101.       When Keyword = 'ATTR' Then Do
  102.          If Right( Data,1 ) <> ';' Then Data = Data';'
  103.          WpsSetup = WpsSetup||Data
  104.          End
  105.  
  106.       When Keyword = 'INSTALL' Then Call BldObj
  107.  
  108.       Otherwise Say 'Keyword' Keyword 'not recognized.'
  109.  
  110.       End /* Select */
  111.  
  112.    End /* Do While */
  113.  
  114. Call Lineout Filename
  115.  
  116. If WpsClass||WpsName||WpsLoc||WpsSetup <> '' Then ,
  117.    Say 'Some data left over - input may be incomplete.'
  118.  
  119. Say Added 'objects successfully created.'
  120. Say Failed 'objects could not be created.'
  121. Exit
  122.  
  123. InitWps:
  124.  
  125.    WpsClass = ''
  126.    WpsName  = ''
  127.    WpsLoc   = ''
  128.    WpsSetup = ''
  129.  
  130. Return;
  131.  
  132.  
  133. /* Build Object */
  134. BldObj:
  135. call charout ,'Building: 'WpsName
  136.  
  137. result = SysCreateObject(WpsClass, WpsName, WpsLoc, WpsSetup)
  138.  
  139. If result=1 Then Do
  140.    call charout ,'...   Object created!'
  141.    Say ''
  142.    Added = Added + 1
  143.    End
  144. Else  Do
  145.    call charout ,'...   Not created! Return code='result
  146.    Say ''
  147.    Failed = Failed + 1
  148.    End
  149.  
  150. Call InitWps
  151.  
  152. Return
  153.