home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / mstdsk.zip / MSTR_DSK.CMD < prev   
OS/2 REXX Batch file  |  1993-05-19  |  42KB  |  1,044 lines

  1. /*
  2.  ╔════════════════════════════════════════════════════════════════════╗
  3.  ║                           MSTR_DSK.CMD                     5/01/93 ║
  4.  ║ by: Steven R. Kobett       Ver. 1.00    CompuServer id: 75716,1576 ║
  5.  ╟────────────────────────────────────────────────────────────────────╢
  6.  ║                          Requirements                              ║
  7.  ║ OS/2 2.0 with the Service Pak installed.                           ║
  8.  ╟────────────────────────────────────────────────────────────────────╢
  9.  ║                          Description                               ║
  10.  ║ This command will build folders and objects on the desktop from    ║
  11.  ║ a text file with a format similar to the DATABASE.TXT supplied     ║
  12.  ║ with OS/2. Objects may be created from the .RC files also          ║
  13.  ║ supplied with OS/2.                                                ║
  14.  ╟────────────────────────────────────────────────────────────────────╢
  15.  ║                             Format                                 ║
  16.  ║ MSTR_DSK options                                                   ║
  17.  ║    /DATABASE:x      - the name of the input file to process.       ║
  18.  ║    /DBTAGS:x        - the name of the file to edit DOS and         ║
  19.  ║                       WINDOWS parameters against.                  ║
  20.  ║    /LOGFILE:x       - the name of the log file.                    ║
  21.  ║    /PREFIX:x        - new prefix for objects.                      ║
  22.  ║    /RCFILE:x        - the name of a .RC file.                      ║
  23.  ║    /SEARCHDRIVE:x:  - the drive to search for EXEs.                ║
  24.  ╟────────────────────────────────────────────────────────────────────╢
  25.  ║                             Example                                ║
  26.  ║ MSTR_DSK /DATABASE:KOBETT.TXT /PREFIX:SRK /LOGFILE:KOBETT.LOG      ║
  27.  ╟────────────────────────────────────────────────────────────────────╢
  28.  ║                      Database Parameters                           ║
  29.  ║                                                                    ║
  30.  ║ SEARCHDRIVE     This parameter specifies the drive to search for   ║
  31.  ║                 executables. An asterisk specifies that all drives ║
  32.  ║                 will be searched.                                  ║
  33.  ║                                                                    ║
  34.  ║ COPYRCOBJECT    This specifies the name of the object in the .RC   ║
  35.  ║                 File whose parameters will be used to create a     ║
  36.  ║                 new object. The new object's id will be the        ║
  37.  ║                 object id from the .RC File prefixed with the      ║
  38.  ║                 value containe in the COPYRCNEWPREFIX parameter.   ║
  39.  ║                                                                    ║
  40.  ║ COPYRCFOLDER    The .RC File is searched for a folder whose        ║
  41.  ║                 objectid matches this value. When found the        ║
  42.  ║                 folder is created and its objectid is prefixed     ║
  43.  ║                 with the value in COPYRCNEWPREFIX. Any object      ║
  44.  ║                 that is found with this value for its location is  ║
  45.  ║                 also created. And its objectid is also prefixed    ║
  46.  ║                 with the value in COPYRCNEWPREFIX.                 ║
  47.  ║                                                                    ║
  48.  ║ COPYRCNEWFOLDER This is used in conjunction with COPYRCFOLDER or   ║
  49.  ║                 COPYRCOBJECT. It specifies a new location for the  ║
  50.  ║                 folder or object being copied.                     ║
  51.  ║                                                                    ║
  52.  ║ COPYRCNEWPREFIX This is used in conjunction with COPYRCFOLDER      ║
  53.  ║                 and COPYRCOBJECT. The value os this parameter      ║
  54.  ║                 is prefixed to the existing objectid.              ║
  55.  ║                                                                    ║
  56.  ║ CLASSNAME       The name os the clsee for this object.             ║
  57.  ║                                                                    ║
  58.  ║ TITLE           The title of the object.                           ║
  59.  ║                                                                    ║
  60.  ║ LOCATION        The location of the object.                        ║
  61.  ║                                                                    ║
  62.  ║ EXECNAME        The name of the program to execute.                ║
  63.  ║                                                                    ║
  64.  ║ WORKINGDIR      The name of the working directory.                 ║
  65.  ║                                                                    ║
  66.  ║ TYPE            The type of program specified in EXECNAME. Valid   ║
  67.  ║                 values are DOS, WINDOWS, or OS/2.                  ║
  68.  ╟────────────────────────────────────────────────────────────────────╢
  69.  ║                           Disclaimer                               ║
  70.  ║ This software and all related materials is being provided on an    ║
  71.  ║ as-is basis. No warranties, guarantees, etc. are expressed or      ║
  72.  ║ implied. The author shall not be liable for any loss of profit,    ║
  73.  ║ data, damages of any type, or any other claims.                    ║
  74.  ║                                                                    ║
  75.  ║ The author grants permission to copy, distribute, and use this     ║
  76.  ║ software and all related materials provided:                       ║
  77.  ║   1. no fee is charged.                                            ║
  78.  ║   2. it is distributed unaltered and in its entirety.              ║
  79.  ╟────────────────────────────────────────────────────────────────────╢
  80.  ║                           Change Log                               ║
  81.  ║ May 1, 1993   Ver. 1.00                                            ║
  82.  ║    Initial release.                                                ║
  83.  ╚════════════════════════════════════════════════════════════════════╝
  84. */
  85.  
  86. MSTR_DSK:
  87.  
  88.    Parse Upper Arg parms
  89.  
  90.    If Pos('?', parms) = 0 Then
  91.       Do
  92.          Call HOUSEKEEPING
  93.          Call BEGIN
  94.          Call FINISHED
  95.       End
  96.    Else
  97.       Call DISPLAY_HELP
  98.  
  99. THEEND:
  100.    Exit
  101.  
  102. HOUSEKEEPING:
  103. /*
  104.  ┌────────────────────────────────────────────────────────────────────┐
  105.  │ The following two lines will register and load the REXX Utilities. │
  106.  └────────────────────────────────────────────────────────────────────┘
  107. */
  108.    Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  109.    Call SysLoadFuncs
  110. /*
  111.  ┌────────────────────────────────────────────────────────────────────┐
  112.  │ The following will initialize the rexx variable named DATABASE.    │
  113.  │ The command line is checked for the DATABASE keyword, /DATABASE:.  │
  114.  │ If found the rexx DATABASE variable is initialized to the value    │
  115.  │ following the keyword. If not found the OS/2 environment space is  │
  116.  │ checked for a variable named DATABASE and if found the rexx        │
  117.  │ DATABASE variable is set to the value of the DATABASE environment  │
  118.  │ variable. If not found the OS/2 USER INI file is querried for the  │
  119.  │ application named MSTR_DSKTP with the key named DATABASE, if found │
  120.  │ the rexx DATABASE variable is set to that value. If the key is not │
  121.  │ found then the rexx DATABASE variable is initialized to the value  │
  122.  │ of "C:\OS2\INSTALL\DATABASE.TXT".                                  │
  123.  └────────────────────────────────────────────────────────────────────┘
  124. */
  125.    Parse Var parms '/DATABASE:'database' '
  126.    If database = "" Then
  127.       Do
  128.          database = Value('DATABASE',,'OS2ENVIRONMENT')
  129.          If database = "" Then
  130.             Do
  131.                database = SysIni(, 'MSTR_DSKTP', 'DATABASE')
  132.                If database = "ERROR:" Then
  133.                   database = "C:\OS2\INSTALL\DATABASE.TXT"
  134.             End
  135.       End
  136.  
  137. /*
  138.  ┌────────────────────────────────────────────────────────────────────┐
  139.  │ The following will initialize the rexx variable named DBTAGS.      │
  140.  │ The command line is checked for the DBTAGS keyword, /DBTAGS:. If   │
  141.  │ found the rexx DBTAGS variable is initialized to the value         │
  142.  │ following the keyword. If not found the OS/2 environment space is  │
  143.  │ checked for a variable named DBTAGS and if found the rexx DBTAGS   │
  144.  │ variable is set to the value of the DBTAGS environment variable.   │
  145.  │ If not found the OS/2 USER INI file is querried for the            │
  146.  │ application named MSTR_DSKTP with the key named DBTAGS, if found   │
  147.  │ the rexx DBTAGS variable is set to that value. If the key is not   │
  148.  │ found then the rexx DBTAGS variable is initialized to the value    │
  149.  │ of "C:\OS2\INSTALL\DBTAGS.DAT".                                    │
  150.  └────────────────────────────────────────────────────────────────────┘
  151. */
  152.    Parse Var parms '/DBTAGS:'dbtags' '
  153.    If dbtags = "" Then
  154.       Do
  155.          dbtags = Value('DBTAGS',,'OS2ENVIRONMENT')
  156.          If dbtags = "" Then
  157.             Do
  158.                dbtags = SysIni(, 'MSTR_DSKTP', 'DBTAGS')
  159.                If dbtags = "ERROR:" Then
  160.                   dbtags = "C:\OS2\INSTALL\DBTAGS.DAT"
  161.             End
  162.       End
  163.  
  164. /*
  165.  ┌────────────────────────────────────────────────────────────────────┐
  166.  │ The following will initialize the rexx variable named LOGFILE.     │
  167.  │ The command line is checked for the LOGFILE keyword, /LOGFILE:.    │
  168.  │ If found the rexx LOGFILE variable is initialized to the value     │
  169.  │ following the keyword. If not found the OS/2 environment space is  │
  170.  │ checked for a variable named LOGFILE and if found the rexx         │
  171.  │ LOGFILE variable is set to the value of the LOGFILE environment    │
  172.  │ variable. If not found the OS/2 USER INI file is querried for the  │
  173.  │ application named MSTR_DSKTP with the key named LOGFILE, if found  │
  174.  │ the rexx LOGFILE variable is set to that value. If the key is not  │
  175.  │ found then the rexx LOGFILE variable is initialized to the value   │
  176.  │ of "MSTR_DSK.LOG".                                                 │
  177.  └────────────────────────────────────────────────────────────────────┘
  178. */
  179.    Parse Var parms '/LOGFILE:'logfile' '
  180.    If logfile = "" Then
  181.       Do
  182.          logfile = Value('LOGFILE',,'OS2ENVIRONMENT')
  183.          If logfile = "" Then
  184.             Do
  185.                logfile = SysIni(, 'MSTR_DSKTP', 'LOGFILE')
  186.                If logfile = "ERROR:" Then
  187.                   logfile = "MSTR_DSK.LOG"
  188.             End
  189.       End
  190.  
  191. /*
  192.  ┌────────────────────────────────────────────────────────────────────┐
  193.  │ The following will initialize the rexx variable named PREFIX.      │
  194.  │ The command line is checked for the PREFIX keyword, /PREFIX:. If   │
  195.  │ found the rexx PREFIX variable is initialized to the value         │
  196.  │ following the keyword. If not found the OS/2 environment space is  │
  197.  │ checked for a variable named PREFIX and if found the rexx PREFIX   │
  198.  │ variable is set to the value of the PREFIX environment variable.   │
  199.  │ If not found the OS/2 USER INI file is querried for the            │
  200.  │ application named MSTR_DSKTP with the key named PREFIX, if found   │
  201.  │ the rexx PREFIX variable is set to that value. If the key is not   │
  202.  │ found then the rexx PREFIX variable is set to NULL.                │
  203.  └────────────────────────────────────────────────────────────────────┘
  204. */
  205.    Parse Var parms '/PREFIX:'prefix' '
  206.    If prefix = "" Then
  207.       Do
  208.          prefix = Value('PREFIX',,'OS2ENVIRONMENT')
  209.          If prefix = "" Then
  210.             Do
  211.                prefix = SysIni(, 'MSTR_DSKTP', 'PREFIX')
  212.                If prefix = "ERROR:" Then
  213.                   prefix = ""
  214.             End
  215.       End
  216.  
  217. /*
  218.  ┌────────────────────────────────────────────────────────────────────┐
  219.  │ The following will initialize the rexx variable named RCFILE.      │
  220.  │ The command line is checked for the RCFILE keyword, /RCFILE:. If   │
  221.  │ found the rexx RCFILE variable is initialized to the value         │
  222.  │ following the keyword. If not found the OS/2 environment space is  │
  223.  │ checked for a variable named RCFILE and if found the rexx RCFILE   │
  224.  │ variable is set to the value of the RCFILE environment variable.   │
  225.  │ If not found the OS/2 USER INI file is querried for the            │
  226.  │ application named MSTR_DSKTP with the key named RCFILE, if found   │
  227.  │ the rexx RCFILE variable is set to that value. If the key is not   │
  228.  │ found then the rexx RCFILE variable is initialized to the value    │
  229.  │ of "C:\OS2\INI.RC".                                                │
  230.  └────────────────────────────────────────────────────────────────────┘
  231. */
  232.    Parse Var parms '/RCFILE:'rcfile' '
  233.    If rcfile = "" Then
  234.       Do
  235.          rcfile = Value('RCFILE',,'OS2ENVIRONMENT')
  236.          If rcfile = "" Then
  237.             Do
  238.                rcfile = SysIni(, 'MSTR_DSKTP', 'RCFILE')
  239.                If rcfile = "ERROR:" Then
  240.                   rcfile = "C:\OS2\INI.RC"
  241.             End
  242.       End
  243.  
  244. /*
  245.  ┌────────────────────────────────────────────────────────────────────┐
  246.  │ The following will initialize the rexx variable named              │
  247.  │ SEARCHDRIVE. The command line is checked for the SEARCHDRIVE       │
  248.  │ keyword, /SEARCHDRIVE:.  If found the rexx SEARCHDRIVE variable    │
  249.  │ is initialized to the value following the keyword. If not found    │
  250.  │ the OS/2 environment space is checked for a variable named         │
  251.  │ SEARCHDRIVE and if found the rexx SEARCHDRIVE variable is set to   │
  252.  │ the value of the SEARCHDRIVE environment variable. If not found    │
  253.  │ the OS/2 USER INI file is querried for the application named       │
  254.  │ MSTR_DSKTP with the key named SEARCHDRIVE, if found the rexx       │
  255.  │ SEARCHDRIVE variable is set to that value. If the key is not       │
  256.  │ found then the rexx SEARCHDRIVE variable is initialized to the     │
  257.  │ value of "*" which will process all drives.                        │
  258.  └────────────────────────────────────────────────────────────────────┘
  259. */
  260.    Parse Var parms '/SEARCHDRIVE:'searchdrive' '
  261.    If searchdrive = "" Then
  262.       Do
  263.          searchdrive = Value('SEARCHDRIVE',,'OS2ENVIRONMENT')
  264.          If searchdrive = "" Then
  265.             Do
  266.                searchdrive = SysIni(, 'MSTR_DSKTP', 'SEARCHDRIVE')
  267.                If searchdrive = "ERROR:" Then
  268.                   searchdrive = "*"
  269.             End
  270.       End
  271.  
  272.  
  273.    subst = 0
  274.    hex0A = '0A'X
  275.    copyrcnewprefix = "xxx"
  276.    copyrcnewfolder = ""
  277.    location = "C:\OS!2 2.0 Desktop\MSTR_DSK FOLDER"
  278.  
  279.    Return
  280.  
  281. FINISHED:
  282.  
  283. /*
  284.  ┌────────────────────────────────────────────────────────────────────┐
  285.  │ The following will save the values of the variables DATABASE,      │
  286.  │ DBTAGS, LOGFILE, PREFIX, RCFILE, SEARCHDRIVE to the OS/2 USER INI  │
  287.  │ file with the application name of MSTR_DSKTP.                      │
  288.  └────────────────────────────────────────────────────────────────────┘
  289. */
  290.    Call SysIni , 'MSTR_DSKTP', 'DATABASE', database
  291.  
  292.    Call SysIni , 'MSTR_DSKTP', 'DBTAGS', dbtags
  293.  
  294.    Call SysIni , 'MSTR_DSKTP', 'LOGFILE', logfile
  295.  
  296.    Call SysIni , 'MSTR_DSKTP', 'PREFIX', prefix
  297.  
  298.    Call SysIni , 'MSTR_DSKTP', 'RCFILE', rcfile
  299.  
  300.    Call SysIni , 'MSTR_DSKTP', 'SEARCHDRIVE', searchdrive
  301.  
  302.    Return
  303.  
  304. DISPLAY_HELP:
  305.  
  306. /*
  307.  ┌────────────────────────────────────────────────────────────────────┐
  308.  │ The following will display the comments at the beginning of this   │
  309.  │ file until the end of comment is found pausing every 24 lines.     │
  310.  └────────────────────────────────────────────────────────────────────┘
  311. */
  312.    sub= 2
  313.    linecount = 1
  314.    Do forever
  315.       If SourceLine(sub) = '*/' Then
  316.          Leave
  317.       Say SourceLine(sub)
  318.       sub = sub + 1
  319.       If linecount = 24 Then
  320.          Do
  321.             "@Pause"
  322.             linecount = 0
  323.          End
  324.       linecount = linecount + 1
  325.    End
  326.    "@Pause"
  327.    Return
  328.  
  329. BEGIN:
  330.  
  331.    Call INITIALIZE
  332.  
  333. /*
  334.  ┌────────────────────────────────────────────────────────────────────┐
  335.  │ The following will load the keywords and the type associated with  │
  336.  │ the keyword from the DBTAGS file. All DOS and Windows KEYWORDS     │
  337.  │ will be edited against this table.                                 │
  338.  └────────────────────────────────────────────────────────────────────┘
  339. */
  340.    db_num = 0
  341.    Do while Lines(dbtags) = 1
  342.       db_in = LineIn(dbtags)
  343.       Parse Upper Var db_in db_in1 db_in2 db_in3 junk
  344.       If db_in1 = "//" Then
  345.          Iterate
  346.       If db_in1 = " " Then
  347.          Iterate
  348.       db_num = db_num + 1
  349.       db_keyword.db_num = db_in2
  350.       db_type.db_num = db_in3
  351.    End
  352.  
  353. /*
  354.  ┌────────────────────────────────────────────────────────────────────┐
  355.  │ This is the main routine of the script. Lines are read from the    │
  356.  │ DATABASE file and edited against the DBTAGS file. If a blank line  │
  357.  │ read or the keyword OBJECTID is found then a desktop object is     │
  358.  │ created.                                                           │
  359.  └────────────────────────────────────────────────────────────────────┘
  360. */
  361.    Do while Lines(database) = 1
  362.       inputrec = LineIn(database)
  363.       Parse Upper Var inputrec keyword junk
  364.       inputrec = DelWord(inputrec,1,1)
  365.       Select
  366.          When keyword = "" Then
  367.             Do
  368.                Select
  369.                   When lastkeyword = "OBJECTID" Then
  370.                      Call INITIALIZE
  371.                   Otherwise
  372.                      Do
  373.                         Call PROCESS
  374.                         Call INITIALIZE
  375.                      End
  376.                End
  377.             End
  378.          Otherwise
  379.             Call EVALUATE
  380.       End
  381.       If keyword = "OBJECTID" Then
  382.          Call PROCESS
  383.       lastkeyword = keyword
  384.    End
  385.    retcode = stream(database, 'c', 'close')
  386.    return
  387.  
  388. EVALUATE:
  389.  
  390. /*
  391.  ┌────────────────────────────────────────────────────────────────────┐
  392.  │ The following will substitute one KEYWORD for another before       │
  393.  │ processing starts.                                                 │
  394.  └────────────────────────────────────────────────────────────────────┘
  395. */
  396.  
  397.    Do i=1 to subst
  398.       If keyword = fromkeyword.i Then
  399.          Do
  400.             keyword = tokeyword.i
  401.             Leave
  402.          End
  403.    End
  404.  
  405.  
  406. /*
  407.  ┌────────────────────────────────────────────────────────────────────┐
  408.  │ In this section keywords are validated, stored and/or processed.   │
  409.  │ Certain keywords, such as COPYRCOBJECT, COPYRCFOLDER, and          │
  410.  │ EXECNAME cause some action to take place.                          │
  411.  └────────────────────────────────────────────────────────────────────┘
  412. */
  413.    Select
  414.       When keyword = "SUBSTITUTEKEYWORD" Then
  415.          Do
  416.             subst = subst + 1
  417.             Parse Upper Var inputrec fromkeyword.subst tokeyword.subst junk
  418.          End
  419.       When keyword = "SEARCHDRIVE" Then
  420.            searchdrive = Strip(inputrec)
  421.       When keyword = "COPYRCNEWFOLDER" Then
  422.            copyrcnewfolder = Strip(inputrec)
  423.       When keyword = "COPYRCNEWPREFIX" Then
  424.            copyrcnewprefix = Strip(inputrec)
  425.       When keyword = "COPYRCOBJECT" Then
  426.            Do
  427.               copyrcobject = Strip(inputrec)
  428.               Call PROCESS_RC
  429.            End
  430.       When keyword = "COPYRCFOLDER" Then
  431.            Do
  432.               copyrcfolder = Strip(inputrec)
  433.               Call PROCESS_RC
  434.            End
  435.       When keyword = "CLASSNAME" Then
  436.            classname = Strip(inputrec)
  437.       When keyword = "TITLE" Then
  438.            title = Strip(inputrec)
  439.       When keyword = "LOCATION" Then
  440.            location = Strip(inputrec)
  441.  
  442.       When keyword = "OBJECTID" Then
  443.            objectid = "OBJECTID="Strip(inputrec)";"
  444.  
  445.       When keyword = "NAME" Then
  446.            Do
  447.               exename = Strip(inputrec)
  448.               Call EVALUATE_EXENAME
  449.               setup = setup"EXENAME="exename";"
  450.            End
  451.       When keyword = "EXECNAME" Then
  452.            Do
  453.               exename = Strip(inputrec)
  454.               Call EVALUATE_EXENAME
  455.               setup = setup"EXENAME="exename";"
  456.            End
  457.  
  458.  
  459.       When keyword = "WORKINGDIR" Then
  460.            If Strip(inputrec) = '*' Then
  461.               setup = setup"STARTUPDIR="Strip(FileSpec("drive",exename)FileSpec("path",exename),'T','\')";"
  462.            Else
  463.               setup = setup"STARTUPDIR="Strip(inputrec)";"
  464.  
  465.       When keyword = "TYPE" Then
  466.          Select
  467.             When SubStr(Strip(inputrec),1,1) = 'D' Then
  468.                setup = setup"PROGTYPE=VDM;"
  469.             When SubStr(Strip(inputrec),1,1) = 'W' Then
  470.                setup = setup"PROGTYPE=WIN;"
  471.             Otherwise
  472.                setup = setup"PROGTYPE=WINDOWABLEVIO;"
  473.          End
  474.       Otherwise
  475.          Do i=1 to db_num
  476.             If keyword = db_keyword.i Then
  477.                Select
  478.                   When db_type.i = "NOP" Then
  479.                     nop
  480.                   When db_type.i = "STR" Then
  481.                     setup = setup"set "keyword"="Strip(inputrec)";"
  482.                   When db_type.i = "BYTE" Then
  483.                     setup = setup"set "keyword"="Strip(inputrec)";"
  484.                   When db_type.i = "BOOL" Then
  485.                     setup = setup"set "keyword"="!ValOnOff(Strip(inputrec))";"
  486.                   When db_type.i = "INT" Then
  487.                     setup = setup"set "keyword"="Strip(inputrec)";"
  488.                   When db_type.i = "MLSTR" Then
  489.                     If keyword = lastkeyword Then
  490.                        setup = Strip(setup,'T',';')hex0A""Strip(Translate(inputrec,' ',','))";"
  491.                     Else
  492.                        setup = setup"set "keyword"="Strip(inputrec)";"
  493.                   When db_type.i = "ENUM" Then
  494.                     setup = setup"set "keyword"="Strip(inputrec)";"
  495.                   Otherwise
  496.                     Do
  497.                        errormsg =  "Invalid TYPE>"db_type.i
  498.                        Call DISPLAYERR
  499.                     End
  500.                End
  501.             If keyword = db_keyword.i Then
  502.                Leave
  503.          End
  504.          If i > db_num Then
  505.             setup = setup""keyword"="Strip(inputrec)";"
  506. /*          Do                                         */
  507. /*             errormsg =  "Invalid keyword>"keyword   */
  508. /*             Call DISPLAYERR                         */
  509. /*          End                                        */
  510.    End
  511.  
  512.    return
  513.  
  514. PROCESS_RC:
  515.  
  516. /*
  517.  ┌────────────────────────────────────────────────────────────────────┐
  518.  │ The following section will process the RCFILE.  Any object or      │
  519.  │ folder that is found in the RCFILE may be added to any other       │
  520.  │ folder on the desktop.                                             │
  521.  └────────────────────────────────────────────────────────────────────┘
  522. */
  523.    savelocation = location
  524.  
  525. /*
  526.  ┌────────────────────────────────────────────────────────────────────┐
  527.  │ A line is read from the RCFILE. The line is scanned for the        │
  528.  │ literal "PM_InstallObject" if found processing continues otherwise │
  529.  │ another line is read. If the line is processed then the data in    │
  530.  │ the line will be used to build one object. This process continues  │
  531.  │ until there are no more lines to be read.                          │
  532.  └────────────────────────────────────────────────────────────────────┘
  533. */
  534.    Do while Lines(rcfile) > 0
  535.       rcdata = LineIn(rcfile)
  536.       Parse Var rcdata '"'test'" ' rcdata
  537.       If test <> "PM_InstallObject" Then
  538.          Iterate
  539. /*
  540.  ┌────────────────────────────────────────────────────────────────────┐
  541.  │ The object's title, settings, class, and location are extraced,    │
  542.  │ or parsed, from the line just read. If the object's class is not   │
  543.  │ Mindex, WPProgram or WPFolder then the line is discarded and       │
  544.  │ processing continues at the beginning of the DO loop where         │
  545.  │ another record is read.                                            │
  546.  └────────────────────────────────────────────────────────────────────┘
  547. */
  548.       Parse Var rcdata '"'titlclsloc'" ' rcdata
  549.       Parse Var rcdata '"'setup'" ' rcdata
  550.       Parse Var titlclsloc title';' titlclsloc
  551.       Parse Var titlclsloc classname';' titlclsloc
  552.       Select
  553.          When classname = "Mindex" then
  554.             Nop
  555.          When classname = "WPProgram" then
  556.             Nop
  557.          When classname = "WPFolder" then
  558.             Nop
  559.          Otherwise
  560.             Iterate
  561.       End
  562.       location = titlclsloc
  563.       setup = Strip(setup,'T','"')
  564. /*
  565.  ┌────────────────────────────────────────────────────────────────────┐
  566.  │ The OBJECTID will be extracted and removed from the setup string.  │
  567.  └────────────────────────────────────────────────────────────────────┘
  568. */
  569.       objidbeg = Pos("OBJECTID=",setup)
  570.       if objidbeg > 0 then
  571.          do
  572.             objidend = Pos(';',setup,objidbeg) - 1
  573.             objidatend = 0
  574.             If objidend = -1 Then
  575.                do
  576.                   objidend = Length(setup)
  577.                   objidatend = 1
  578.                end
  579.             objid = SubStr(setup,objidbeg + 9,objidend - objidbeg - 8)
  580.             Select
  581.                When Length(setup) = Length(objid) + 9 Then
  582.                   setup = ""
  583.                When objidbeg = 1 Then
  584.                   setup = Right(setup,Length(setup) - Length(objid) - 10)
  585.                When objidatend = 1 Then
  586.                   setup = Left(setup,Length(setup) - Length(objid) - 10)
  587.                Otherwise
  588.                   setup = Left(setup,Length(setup) - objidbeg - 13)Right(setup,Length(setup) - objidend - 1)
  589.             End
  590.          End
  591. /*
  592.  ┌────────────────────────────────────────────────────────────────────┐
  593.  │ If the keyword COPYRCFOLDER is being processed then the only valid │
  594.  │ classes are "Mindex" or "WPProgram".  If an invalid class is found │
  595.  │ then processing continues at the top of the do loop where another  │
  596.  │ line is read.                                                      │
  597.  └────────────────────────────────────────────────────────────────────┘
  598. */
  599.       If copyrcobject <> "" then
  600.          Select
  601.             When classname = "Mindex" then
  602.                If objid <> '<'copyrcobject'>' then
  603.                   Iterate
  604.             When classname = "WPProgram" then
  605.                If objid <> '<'copyrcobject'>' then
  606.                   Iterate
  607.             Otherwise
  608.                Iterate
  609.          End
  610. /*
  611.  ┌────────────────────────────────────────────────────────────────────┐
  612.  │ If the keyword COPYRCOBJECT is being processed then the only valid │
  613.  │ classes are "Mindex", "WPProgram" or "WPFOLDER".  If an invalid    │
  614.  │ class is found then processing continues at the top of th do loop  │
  615.  │ where another line is read.                                        │
  616.  └────────────────────────────────────────────────────────────────────┘
  617. */
  618.       Else
  619.          Select
  620.             When classname = "Mindex" then
  621.                   If location <> '<'copyrcfolder'>' then
  622.                      Iterate
  623.             When classname = "WPProgram" then
  624.                   If location <> '<'copyrcfolder'>' then
  625.                      Iterate
  626.             When classname = "WPFolder" then
  627.                   If objid <> '<'copyrcfolder'>' then
  628.                      Iterate
  629.             Otherwise
  630.                Iterate
  631.          End
  632. /*
  633.  ┌────────────────────────────────────────────────────────────────────┐
  634.  │ The OBJECTID is given a new prefix and the object may be given a   │
  635.  │ new location.                                                      │
  636.  └────────────────────────────────────────────────────────────────────┘
  637. */
  638.       objid = '<'copyrcnewprefix''SubStr(objid,Pos('_',objid))
  639.       objectid = "OBJECTID="objid";"
  640.       If classname = "Mindex" Then
  641.          If copyrcnewfolder = "" Then
  642.             location = savelocation
  643.          Else
  644.             Nop
  645.       Else
  646.          If classname = "WPFolder" Then
  647.             If copyrcnewfolder = "" Then
  648.                location = savelocation
  649.             Else
  650.                Iterate
  651.          Else
  652.             if SubStr(location,1,1) = '<' then
  653.                location = '<'copyrcnewprefix''SubStr(location,Pos('_',location))
  654.       If copyrcnewfolder <> "" Then
  655.          location = '<'copyrcnewfolder'>'
  656. /*
  657.  ┌────────────────────────────────────────────────────────────────────┐
  658.  │ The object is set as deletable and then the the PROCESS section is │
  659.  │ called to create the object. If a COPYRCOBJECT was being processed │
  660.  │ then the DO loop is terminated, however, if a COPYRCFOLDER is      │
  661.  │ being processed then processing continues at the top of the DO     │
  662.  │ loop where another line read. The entire RCFILE will be read for   │
  663.  │ the objects that belong to this folder.                            │
  664.  └────────────────────────────────────────────────────────────────────┘
  665. */
  666.       setup = setup";NODELETE=NO"
  667.       Call PROCESS
  668.       If copyrcobject <> "" then
  669.          Leave
  670.    End
  671.  
  672. /*
  673.  ┌────────────────────────────────────────────────────────────────────┐
  674.  │ The location variable is restored to its previous value and the    │
  675.  │ other variables used are initialized.                              │
  676.  └────────────────────────────────────────────────────────────────────┘
  677. */
  678.    location = savelocation
  679.    retcode = stream(rcfile, 'c', 'close')
  680.    Call INITIALIZE
  681.    Return
  682.  
  683. EVALUATE_EXENAME:
  684.  
  685. /*
  686.  ┌────────────────────────────────────────────────────────────────────┐
  687.  │ This section will search for the executable (.EXE, .COM, .BAT,     │
  688.  │ .CMD) on all physical or logical drives. When found the original   │
  689.  │ name is replaced by the fully qualified filename. If the name      │
  690.  │ is an asterisk then this section is exited.                        │
  691.  └────────────────────────────────────────────────────────────────────┘
  692. */
  693.    If exename = "*" Then
  694.       return
  695.  
  696. /*
  697.  ┌────────────────────────────────────────────────────────────────────┐
  698.  │ The second position of the name is checked for a colon. This       │
  699.  │ indicates that the name is already fully qualified.                │
  700.  └────────────────────────────────────────────────────────────────────┘
  701. */
  702.    If SubStr(FileSpec("drive",exename), 2, 1) = ":" Then
  703.       return
  704.  
  705. /*
  706.  ┌────────────────────────────────────────────────────────────────────┐
  707.  │ The following sets which drives will be searched for executables.  │
  708.  │ If an asterisk is in the DATABASE parameter SEARCHDRIVE then       │
  709.  │ all drives will be searched. If the SEARCHDRIVE variable contains  │
  710.  │ a drive letter then only that drive is searched, however if it is  │
  711.  │ not a valid drive then all drives will be searched.                │
  712.  └────────────────────────────────────────────────────────────────────┘
  713. */
  714.    drivesinuse = SysDriveMap('C:','USED')
  715.    If searchdrive <> '*' Then
  716.       If WordPos(searchdrive,drivesinuse) > 0 Then
  717.          drivesinuse = searchdrive
  718.    Say "Processing drives:" drivesinuse
  719.  
  720. /*
  721.  ┌────────────────────────────────────────────────────────────────────┐
  722.  │ The following creates a table of fully qualified filenames based   │
  723.  │ the executable name. Note that it is possible not to specify a     │
  724.  │ drive letter and still specify an absolute or relative path for    │
  725.  │ the executable.                                                    │
  726.  └────────────────────────────────────────────────────────────────────┘
  727. */
  728.    found.0 = 0
  729.    Do words(drivesinuse)
  730.       Call SysFileTree word(drivesinuse,1)'\'FileSpec("name",exename), 'file', 'SFO'
  731.       If file.0 > 0 Then
  732.          Do i=1 to file.0
  733.             found.0 = found.0 + 1
  734.             j = found.0
  735.             found.j = file.i
  736.          End
  737.       drivesinuse = Subword(drivesinuse,2)
  738.    End
  739.  
  740. /*
  741.  ┌────────────────────────────────────────────────────────────────────┐
  742.  │ If the executable was not found a message is displayed and the     │
  743.  │ section is exited.                                                 │
  744.  └────────────────────────────────────────────────────────────────────┘
  745. */
  746.    If found.0 = 0 Then
  747.       Do
  748.          errormsg = "The EXENAME="exename" was not found"
  749.          Call DISPLAYERR
  750.          abortind = 1
  751.          return
  752.       End
  753.  
  754. /*
  755.  ┌────────────────────────────────────────────────────────────────────┐
  756.  │ The following will create another table of fully qualified file    │
  757.  │ names. If the executable was specified with a partial path and     │
  758.  │ the executable does exist along that path then those entries are   │
  759.  │ written to the new table.                                          │
  760.  └────────────────────────────────────────────────────────────────────┘
  761. */
  762.    selected.0 = 0
  763.    Do i=1 to found.0
  764.       If exename = Right(found.i,Length(exename)) Then
  765.          Do
  766.             selected.0 = selected.0 + 1
  767.             j = selected.0
  768.             selected.j = found.i
  769.          End
  770.    End
  771.  
  772. /*
  773.  ┌────────────────────────────────────────────────────────────────────┐
  774.  │ If only one fully qualified name was found then replace the        │
  775.  │ previous name with the fully quallified name and exit.             │
  776.  └────────────────────────────────────────────────────────────────────┘
  777. */
  778.    If selected.0 = 1 Then
  779.       Do
  780.          exename = selected.1
  781.          return
  782.       End
  783.  
  784. /*
  785.  ┌────────────────────────────────────────────────────────────────────┐
  786.  │ If the executable was found on a drive but not along the path      │
  787.  │ specified then an error is displayed and processing continues.     │
  788.  └────────────────────────────────────────────────────────────────────┘
  789. */
  790.    If selected.0 = 0 Then
  791.       Do
  792.          errormsg = "The EXENAME="exename" was not found but the executable" FileSpec("name",exename) "was!"
  793.          Call DISPLAYERR
  794.       End
  795.  
  796. /*
  797.  ┌────────────────────────────────────────────────────────────────────┐
  798.  │ The executable was found on a drive and along the specified path.  │
  799.  │ The original table that contains all the fully qualified names     │
  800.  │ is replaced with the table was filtered by the absolute or         │
  801.  │ relative path.                                                     │
  802.  └────────────────────────────────────────────────────────────────────┘
  803. */
  804.    If selected.0 > 0 Then
  805.       Do i=0 to selected.0
  806.          found.i = selected.i
  807.       End
  808.  
  809. /*
  810.  ┌────────────────────────────────────────────────────────────────────┐
  811.  │ The fully qualified file names are displayed and the user is       │
  812.  │ prompted to make a selection. The selection is validated.          │
  813.  └────────────────────────────────────────────────────────────────────┘
  814. */
  815.       selected = 0
  816.       Do until selected = 1
  817.          Do i=1 to found.0
  818.             drive = FileSpec("drive",found.i)
  819.             path = Strip(FileSpec("path",found.i), "T", "\")
  820.             drivepath =  drive""path
  821.             If i = 1 Then
  822.                Do
  823.                   response = "The executable "exename" was found in multiple directories!"
  824.                   Call DISPLAYRSP
  825.                   response = "Select the appropriate directory or 0 to bypass:"
  826.                   Call DISPLAYRSP
  827.                End
  828.             response =  "   "i"." drivepath
  829.             Call DISPLAYRSP
  830.          End
  831.          pull answer
  832.          If answer = 0 Then
  833.             Do
  834.                errormsg =  "Entry aborted!"
  835.                Call DISPLAYERR
  836.                abortind = 1
  837.                return
  838.             End
  839.          If answer > 0 Then
  840.             If answer < found.0 + 1 Then
  841.                Do
  842.                   response =  "selected: " found.answer
  843.                   Call DISPLAYRSP
  844.                   exename = found.answer
  845.                   selected = 1
  846.                End
  847.       End
  848.  
  849.    return
  850.  
  851. PROCESS:
  852.  
  853. /*
  854.  ┌────────────────────────────────────────────────────────────────────┐
  855.  │ This section determines if the object should be processed.         │
  856.  └────────────────────────────────────────────────────────────────────┘
  857. */
  858.    If prefix <> '' Then
  859.       Do
  860.          bypassind = 0
  861.          If SubStr(objectid,10,Length(prefix)+1) <> '<'prefix Then
  862.             bypassind = bypassind + 1
  863.          If SubStr(location,1,Length(prefix)+1) <> '<'prefix Then
  864.             bypassind = bypassind + 1
  865.          If bypassind > 1 Then
  866.             return
  867.       End
  868.  
  869.    If abortind = 1 Then
  870.       Do
  871.          abortind = 0
  872.          return
  873.       End
  874.  
  875.    If title <> "" Then
  876.       Call MAKE_OBJECT
  877.  
  878.    return
  879.  
  880. INITIALIZE:
  881. /*
  882.  ┌────────────────────────────────────────────────────────────────────┐
  883.  │ This section initializes most of the variables used to process an  │
  884.  │ object.                                                            │
  885.  └────────────────────────────────────────────────────────────────────┘
  886. */
  887.  
  888. /* SysCreateObject variables */
  889.    classname = "WPProgram"
  890.    title = ""
  891.    setup = ""
  892.    duplicateflag = "U"
  893.  
  894.    objectid = ""
  895.  
  896.    exename = ""
  897.    progtype = ""
  898.  
  899.    copyrcobject = ""
  900.    copyrcfolder = ""
  901.  
  902. /* miscellanoues variables */
  903.  
  904.    exepath = ""
  905.  
  906.    return
  907.  
  908.  
  909. MAKE_OBJECT:
  910.  
  911. /*
  912.  ┌────────────────────────────────────────────────────────────────────┐
  913.  │ This section processes the object, displays rather the process was │
  914.  │ successful or not, and logs the information to a file.             │
  915.  └────────────────────────────────────────────────────────────────────┘
  916. */
  917.    objsetup = objectid""setup
  918.  
  919.    RetCode = SysCreateObject(classname,,
  920.                              title,,
  921.                              location,,
  922.                              objsetup,,
  923.                              duplicateflag)
  924.  
  925.    If retcode = 1 Then
  926.       retdesc = "Status: Successful"
  927.    Else
  928.       retdesc = "Status: Unsuccessful"
  929.  
  930.    line1 =  " "
  931.    line2 =  Date() Time() "Classname:     " classname
  932.    line3 =  Date() Time() "Title:         " title
  933.    line4 =  Date() Time() "Location:      " location
  934.    line5 =  Date() Time() "Setup:         " objsetup
  935.    line6 =  Date() Time() "Duplicateflag: " duplicateflag
  936.    line7 =  retdesc
  937.  
  938.    say line1
  939.    say line2
  940.    say line3
  941.    say line4
  942.    say line5
  943.    say line6
  944.    say line7
  945.  
  946.    rc = lineout(logfile, line1)
  947.    rc = lineout(logfile, line2)
  948.    rc = lineout(logfile, line3)
  949.    rc = lineout(logfile, line4)
  950.    rc = lineout(logfile, line5)
  951.    rc = lineout(logfile, line6)
  952.    rc = lineout(logfile, line7)
  953.  
  954.    return
  955.  
  956. !ValOnOff:
  957. /*
  958.  ┌────────────────────────────────────────────────────────────────────┐
  959.  │ This function will accept a value of "ON" or 1 to return a value   │
  960.  │ of 1 otherwise it will return a value of 0.                        │
  961.  │ Ex. x = ValOnOff("on") will set the value of x to 1.               │
  962.  │     x = ValOnOff(1) will set the value of x to 1.                  │
  963.  │     x = ValOnOff("Off") will set the value of x to 0.              │
  964.  │     x = ValOnOff(0) will set the value of x to 0.                  │
  965.  │     x = ValOnOff("xYz") will set the value of x to 0.              │
  966.  └────────────────────────────────────────────────────────────────────┘
  967. */
  968.    parse upper arg ansonoff
  969.    Select
  970.       When substr(ansonoff, 1, 2) = 'ON' Then
  971.          return(1)
  972.       When substr(ansonoff, 1, 1) = '1' Then
  973.          return(1)
  974.       Otherwise
  975.          return(0)
  976.    End
  977.    return(0)
  978.  
  979. !ValYesNo:
  980. /*
  981.  ┌────────────────────────────────────────────────────────────────────┐
  982.  │ This function will accept a value of "YES" or 1 to return a value  │
  983.  │ of 1 otherwise it will return a value of 0.                        │
  984.  │ Ex. x = ValYesNo("yes") will set the value of x to 1.              │
  985.  │     x = ValYesNo(1) will set the value of x to 1.                  │
  986.  │     x = ValYesNo("no") will set the value of x to 0.               │
  987.  │     x = ValYesNo(0) will set the value of x to 0.                  │
  988.  │     x = ValYesNo("xYz") will set the value of x to 0.              │
  989.  └────────────────────────────────────────────────────────────────────┘
  990. */
  991.    parse upper arg ansyesno
  992.    Select
  993.       When substr(ansyesno, 1, 2) = 'YES' Then
  994.          return(1)
  995.       When substr(ansyesno, 1, 1) = '1' Then
  996.          return(1)
  997.       Otherwise
  998.          return(0)
  999.    End
  1000.    return(0)
  1001.  
  1002.  
  1003. DISPLAYRESET:
  1004. /*
  1005.  ┌────────────────────────────────────────────────────────────────────┐
  1006.  │ Reset the display to its default foreground and background colors. │
  1007.  └────────────────────────────────────────────────────────────────────┘
  1008. */
  1009.    say ""
  1010.    return
  1011.  
  1012. DISPLAYRSP:
  1013. /*
  1014.  ┌────────────────────────────────────────────────────────────────────┐
  1015.  │ This will display the value of the variable RESPONSE in yellow on  │
  1016.  │ a blue background.                                                 │
  1017.  └────────────────────────────────────────────────────────────────────┘
  1018. */
  1019.    say ""response""
  1020.  
  1021.    line1 =  " "
  1022.    line2 =  Date() Time() "Response:     " response
  1023.    rc = lineout(logfile, line1)
  1024.    rc = lineout(logfile, line2)
  1025.  
  1026.    return
  1027.  
  1028. DISPLAYERR:
  1029. /*
  1030.  ┌────────────────────────────────────────────────────────────────────┐
  1031.  │ This will display the value of the variable ERRORMSG in white on a │
  1032.  │ blue background.                                                   │
  1033.  └────────────────────────────────────────────────────────────────────┘
  1034. */
  1035.    say ""errormsg""
  1036.  
  1037.    line1 =  " "
  1038.    line2 =  Date() Time() "Error:        " errormsg
  1039.    rc = lineout(logfile, line1)
  1040.    rc = lineout(logfile, line2)
  1041.  
  1042.    return
  1043.  
  1044.