home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
mstdsk.zip
/
MSTR_DSK.CMD
< prev
Wrap
OS/2 REXX Batch file
|
1993-05-19
|
42KB
|
1,044 lines
/*
╔════════════════════════════════════════════════════════════════════╗
║ MSTR_DSK.CMD 5/01/93 ║
║ by: Steven R. Kobett Ver. 1.00 CompuServer id: 75716,1576 ║
╟────────────────────────────────────────────────────────────────────╢
║ Requirements ║
║ OS/2 2.0 with the Service Pak installed. ║
╟────────────────────────────────────────────────────────────────────╢
║ Description ║
║ This command will build folders and objects on the desktop from ║
║ a text file with a format similar to the DATABASE.TXT supplied ║
║ with OS/2. Objects may be created from the .RC files also ║
║ supplied with OS/2. ║
╟────────────────────────────────────────────────────────────────────╢
║ Format ║
║ MSTR_DSK options ║
║ /DATABASE:x - the name of the input file to process. ║
║ /DBTAGS:x - the name of the file to edit DOS and ║
║ WINDOWS parameters against. ║
║ /LOGFILE:x - the name of the log file. ║
║ /PREFIX:x - new prefix for objects. ║
║ /RCFILE:x - the name of a .RC file. ║
║ /SEARCHDRIVE:x: - the drive to search for EXEs. ║
╟────────────────────────────────────────────────────────────────────╢
║ Example ║
║ MSTR_DSK /DATABASE:KOBETT.TXT /PREFIX:SRK /LOGFILE:KOBETT.LOG ║
╟────────────────────────────────────────────────────────────────────╢
║ Database Parameters ║
║ ║
║ SEARCHDRIVE This parameter specifies the drive to search for ║
║ executables. An asterisk specifies that all drives ║
║ will be searched. ║
║ ║
║ COPYRCOBJECT This specifies the name of the object in the .RC ║
║ File whose parameters will be used to create a ║
║ new object. The new object's id will be the ║
║ object id from the .RC File prefixed with the ║
║ value containe in the COPYRCNEWPREFIX parameter. ║
║ ║
║ COPYRCFOLDER The .RC File is searched for a folder whose ║
║ objectid matches this value. When found the ║
║ folder is created and its objectid is prefixed ║
║ with the value in COPYRCNEWPREFIX. Any object ║
║ that is found with this value for its location is ║
║ also created. And its objectid is also prefixed ║
║ with the value in COPYRCNEWPREFIX. ║
║ ║
║ COPYRCNEWFOLDER This is used in conjunction with COPYRCFOLDER or ║
║ COPYRCOBJECT. It specifies a new location for the ║
║ folder or object being copied. ║
║ ║
║ COPYRCNEWPREFIX This is used in conjunction with COPYRCFOLDER ║
║ and COPYRCOBJECT. The value os this parameter ║
║ is prefixed to the existing objectid. ║
║ ║
║ CLASSNAME The name os the clsee for this object. ║
║ ║
║ TITLE The title of the object. ║
║ ║
║ LOCATION The location of the object. ║
║ ║
║ EXECNAME The name of the program to execute. ║
║ ║
║ WORKINGDIR The name of the working directory. ║
║ ║
║ TYPE The type of program specified in EXECNAME. Valid ║
║ values are DOS, WINDOWS, or OS/2. ║
╟────────────────────────────────────────────────────────────────────╢
║ Disclaimer ║
║ This software and all related materials is being provided on an ║
║ as-is basis. No warranties, guarantees, etc. are expressed or ║
║ implied. The author shall not be liable for any loss of profit, ║
║ data, damages of any type, or any other claims. ║
║ ║
║ The author grants permission to copy, distribute, and use this ║
║ software and all related materials provided: ║
║ 1. no fee is charged. ║
║ 2. it is distributed unaltered and in its entirety. ║
╟────────────────────────────────────────────────────────────────────╢
║ Change Log ║
║ May 1, 1993 Ver. 1.00 ║
║ Initial release. ║
╚════════════════════════════════════════════════════════════════════╝
*/
MSTR_DSK:
Parse Upper Arg parms
If Pos('?', parms) = 0 Then
Do
Call HOUSEKEEPING
Call BEGIN
Call FINISHED
End
Else
Call DISPLAY_HELP
THEEND:
Exit
HOUSEKEEPING:
/*
┌────────────────────────────────────────────────────────────────────┐
│ The following two lines will register and load the REXX Utilities. │
└────────────────────────────────────────────────────────────────────┘
*/
Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
Call SysLoadFuncs
/*
┌────────────────────────────────────────────────────────────────────┐
│ The following will initialize the rexx variable named DATABASE. │
│ The command line is checked for the DATABASE keyword, /DATABASE:. │
│ If found the rexx DATABASE variable is initialized to the value │
│ following the keyword. If not found the OS/2 environment space is │
│ checked for a variable named DATABASE and if found the rexx │
│ DATABASE variable is set to the value of the DATABASE environment │
│ variable. If not found the OS/2 USER INI file is querried for the │
│ application named MSTR_DSKTP with the key named DATABASE, if found │
│ the rexx DATABASE variable is set to that value. If the key is not │
│ found then the rexx DATABASE variable is initialized to the value │
│ of "C:\OS2\INSTALL\DATABASE.TXT". │
└────────────────────────────────────────────────────────────────────┘
*/
Parse Var parms '/DATABASE:'database' '
If database = "" Then
Do
database = Value('DATABASE',,'OS2ENVIRONMENT')
If database = "" Then
Do
database = SysIni(, 'MSTR_DSKTP', 'DATABASE')
If database = "ERROR:" Then
database = "C:\OS2\INSTALL\DATABASE.TXT"
End
End
/*
┌────────────────────────────────────────────────────────────────────┐
│ The following will initialize the rexx variable named DBTAGS. │
│ The command line is checked for the DBTAGS keyword, /DBTAGS:. If │
│ found the rexx DBTAGS variable is initialized to the value │
│ following the keyword. If not found the OS/2 environment space is │
│ checked for a variable named DBTAGS and if found the rexx DBTAGS │
│ variable is set to the value of the DBTAGS environment variable. │
│ If not found the OS/2 USER INI file is querried for the │
│ application named MSTR_DSKTP with the key named DBTAGS, if found │
│ the rexx DBTAGS variable is set to that value. If the key is not │
│ found then the rexx DBTAGS variable is initialized to the value │
│ of "C:\OS2\INSTALL\DBTAGS.DAT". │
└────────────────────────────────────────────────────────────────────┘
*/
Parse Var parms '/DBTAGS:'dbtags' '
If dbtags = "" Then
Do
dbtags = Value('DBTAGS',,'OS2ENVIRONMENT')
If dbtags = "" Then
Do
dbtags = SysIni(, 'MSTR_DSKTP', 'DBTAGS')
If dbtags = "ERROR:" Then
dbtags = "C:\OS2\INSTALL\DBTAGS.DAT"
End
End
/*
┌────────────────────────────────────────────────────────────────────┐
│ The following will initialize the rexx variable named LOGFILE. │
│ The command line is checked for the LOGFILE keyword, /LOGFILE:. │
│ If found the rexx LOGFILE variable is initialized to the value │
│ following the keyword. If not found the OS/2 environment space is │
│ checked for a variable named LOGFILE and if found the rexx │
│ LOGFILE variable is set to the value of the LOGFILE environment │
│ variable. If not found the OS/2 USER INI file is querried for the │
│ application named MSTR_DSKTP with the key named LOGFILE, if found │
│ the rexx LOGFILE variable is set to that value. If the key is not │
│ found then the rexx LOGFILE variable is initialized to the value │
│ of "MSTR_DSK.LOG". │
└────────────────────────────────────────────────────────────────────┘
*/
Parse Var parms '/LOGFILE:'logfile' '
If logfile = "" Then
Do
logfile = Value('LOGFILE',,'OS2ENVIRONMENT')
If logfile = "" Then
Do
logfile = SysIni(, 'MSTR_DSKTP', 'LOGFILE')
If logfile = "ERROR:" Then
logfile = "MSTR_DSK.LOG"
End
End
/*
┌────────────────────────────────────────────────────────────────────┐
│ The following will initialize the rexx variable named PREFIX. │
│ The command line is checked for the PREFIX keyword, /PREFIX:. If │
│ found the rexx PREFIX variable is initialized to the value │
│ following the keyword. If not found the OS/2 environment space is │
│ checked for a variable named PREFIX and if found the rexx PREFIX │
│ variable is set to the value of the PREFIX environment variable. │
│ If not found the OS/2 USER INI file is querried for the │
│ application named MSTR_DSKTP with the key named PREFIX, if found │
│ the rexx PREFIX variable is set to that value. If the key is not │
│ found then the rexx PREFIX variable is set to NULL. │
└────────────────────────────────────────────────────────────────────┘
*/
Parse Var parms '/PREFIX:'prefix' '
If prefix = "" Then
Do
prefix = Value('PREFIX',,'OS2ENVIRONMENT')
If prefix = "" Then
Do
prefix = SysIni(, 'MSTR_DSKTP', 'PREFIX')
If prefix = "ERROR:" Then
prefix = ""
End
End
/*
┌────────────────────────────────────────────────────────────────────┐
│ The following will initialize the rexx variable named RCFILE. │
│ The command line is checked for the RCFILE keyword, /RCFILE:. If │
│ found the rexx RCFILE variable is initialized to the value │
│ following the keyword. If not found the OS/2 environment space is │
│ checked for a variable named RCFILE and if found the rexx RCFILE │
│ variable is set to the value of the RCFILE environment variable. │
│ If not found the OS/2 USER INI file is querried for the │
│ application named MSTR_DSKTP with the key named RCFILE, if found │
│ the rexx RCFILE variable is set to that value. If the key is not │
│ found then the rexx RCFILE variable is initialized to the value │
│ of "C:\OS2\INI.RC". │
└────────────────────────────────────────────────────────────────────┘
*/
Parse Var parms '/RCFILE:'rcfile' '
If rcfile = "" Then
Do
rcfile = Value('RCFILE',,'OS2ENVIRONMENT')
If rcfile = "" Then
Do
rcfile = SysIni(, 'MSTR_DSKTP', 'RCFILE')
If rcfile = "ERROR:" Then
rcfile = "C:\OS2\INI.RC"
End
End
/*
┌────────────────────────────────────────────────────────────────────┐
│ The following will initialize the rexx variable named │
│ SEARCHDRIVE. The command line is checked for the SEARCHDRIVE │
│ keyword, /SEARCHDRIVE:. If found the rexx SEARCHDRIVE variable │
│ is initialized to the value following the keyword. If not found │
│ the OS/2 environment space is checked for a variable named │
│ SEARCHDRIVE and if found the rexx SEARCHDRIVE variable is set to │
│ the value of the SEARCHDRIVE environment variable. If not found │
│ the OS/2 USER INI file is querried for the application named │
│ MSTR_DSKTP with the key named SEARCHDRIVE, if found the rexx │
│ SEARCHDRIVE variable is set to that value. If the key is not │
│ found then the rexx SEARCHDRIVE variable is initialized to the │
│ value of "*" which will process all drives. │
└────────────────────────────────────────────────────────────────────┘
*/
Parse Var parms '/SEARCHDRIVE:'searchdrive' '
If searchdrive = "" Then
Do
searchdrive = Value('SEARCHDRIVE',,'OS2ENVIRONMENT')
If searchdrive = "" Then
Do
searchdrive = SysIni(, 'MSTR_DSKTP', 'SEARCHDRIVE')
If searchdrive = "ERROR:" Then
searchdrive = "*"
End
End
subst = 0
hex0A = '0A'X
copyrcnewprefix = "xxx"
copyrcnewfolder = ""
location = "C:\OS!2 2.0 Desktop\MSTR_DSK FOLDER"
Return
FINISHED:
/*
┌────────────────────────────────────────────────────────────────────┐
│ The following will save the values of the variables DATABASE, │
│ DBTAGS, LOGFILE, PREFIX, RCFILE, SEARCHDRIVE to the OS/2 USER INI │
│ file with the application name of MSTR_DSKTP. │
└────────────────────────────────────────────────────────────────────┘
*/
Call SysIni , 'MSTR_DSKTP', 'DATABASE', database
Call SysIni , 'MSTR_DSKTP', 'DBTAGS', dbtags
Call SysIni , 'MSTR_DSKTP', 'LOGFILE', logfile
Call SysIni , 'MSTR_DSKTP', 'PREFIX', prefix
Call SysIni , 'MSTR_DSKTP', 'RCFILE', rcfile
Call SysIni , 'MSTR_DSKTP', 'SEARCHDRIVE', searchdrive
Return
DISPLAY_HELP:
/*
┌────────────────────────────────────────────────────────────────────┐
│ The following will display the comments at the beginning of this │
│ file until the end of comment is found pausing every 24 lines. │
└────────────────────────────────────────────────────────────────────┘
*/
sub= 2
linecount = 1
Do forever
If SourceLine(sub) = '*/' Then
Leave
Say SourceLine(sub)
sub = sub + 1
If linecount = 24 Then
Do
"@Pause"
linecount = 0
End
linecount = linecount + 1
End
"@Pause"
Return
BEGIN:
Call INITIALIZE
/*
┌────────────────────────────────────────────────────────────────────┐
│ The following will load the keywords and the type associated with │
│ the keyword from the DBTAGS file. All DOS and Windows KEYWORDS │
│ will be edited against this table. │
└────────────────────────────────────────────────────────────────────┘
*/
db_num = 0
Do while Lines(dbtags) = 1
db_in = LineIn(dbtags)
Parse Upper Var db_in db_in1 db_in2 db_in3 junk
If db_in1 = "//" Then
Iterate
If db_in1 = " " Then
Iterate
db_num = db_num + 1
db_keyword.db_num = db_in2
db_type.db_num = db_in3
End
/*
┌────────────────────────────────────────────────────────────────────┐
│ This is the main routine of the script. Lines are read from the │
│ DATABASE file and edited against the DBTAGS file. If a blank line │
│ read or the keyword OBJECTID is found then a desktop object is │
│ created. │
└────────────────────────────────────────────────────────────────────┘
*/
Do while Lines(database) = 1
inputrec = LineIn(database)
Parse Upper Var inputrec keyword junk
inputrec = DelWord(inputrec,1,1)
Select
When keyword = "" Then
Do
Select
When lastkeyword = "OBJECTID" Then
Call INITIALIZE
Otherwise
Do
Call PROCESS
Call INITIALIZE
End
End
End
Otherwise
Call EVALUATE
End
If keyword = "OBJECTID" Then
Call PROCESS
lastkeyword = keyword
End
retcode = stream(database, 'c', 'close')
return
EVALUATE:
/*
┌────────────────────────────────────────────────────────────────────┐
│ The following will substitute one KEYWORD for another before │
│ processing starts. │
└────────────────────────────────────────────────────────────────────┘
*/
Do i=1 to subst
If keyword = fromkeyword.i Then
Do
keyword = tokeyword.i
Leave
End
End
/*
┌────────────────────────────────────────────────────────────────────┐
│ In this section keywords are validated, stored and/or processed. │
│ Certain keywords, such as COPYRCOBJECT, COPYRCFOLDER, and │
│ EXECNAME cause some action to take place. │
└────────────────────────────────────────────────────────────────────┘
*/
Select
When keyword = "SUBSTITUTEKEYWORD" Then
Do
subst = subst + 1
Parse Upper Var inputrec fromkeyword.subst tokeyword.subst junk
End
When keyword = "SEARCHDRIVE" Then
searchdrive = Strip(inputrec)
When keyword = "COPYRCNEWFOLDER" Then
copyrcnewfolder = Strip(inputrec)
When keyword = "COPYRCNEWPREFIX" Then
copyrcnewprefix = Strip(inputrec)
When keyword = "COPYRCOBJECT" Then
Do
copyrcobject = Strip(inputrec)
Call PROCESS_RC
End
When keyword = "COPYRCFOLDER" Then
Do
copyrcfolder = Strip(inputrec)
Call PROCESS_RC
End
When keyword = "CLASSNAME" Then
classname = Strip(inputrec)
When keyword = "TITLE" Then
title = Strip(inputrec)
When keyword = "LOCATION" Then
location = Strip(inputrec)
When keyword = "OBJECTID" Then
objectid = "OBJECTID="Strip(inputrec)";"
When keyword = "NAME" Then
Do
exename = Strip(inputrec)
Call EVALUATE_EXENAME
setup = setup"EXENAME="exename";"
End
When keyword = "EXECNAME" Then
Do
exename = Strip(inputrec)
Call EVALUATE_EXENAME
setup = setup"EXENAME="exename";"
End
When keyword = "WORKINGDIR" Then
If Strip(inputrec) = '*' Then
setup = setup"STARTUPDIR="Strip(FileSpec("drive",exename)FileSpec("path",exename),'T','\')";"
Else
setup = setup"STARTUPDIR="Strip(inputrec)";"
When keyword = "TYPE" Then
Select
When SubStr(Strip(inputrec),1,1) = 'D' Then
setup = setup"PROGTYPE=VDM;"
When SubStr(Strip(inputrec),1,1) = 'W' Then
setup = setup"PROGTYPE=WIN;"
Otherwise
setup = setup"PROGTYPE=WINDOWABLEVIO;"
End
Otherwise
Do i=1 to db_num
If keyword = db_keyword.i Then
Select
When db_type.i = "NOP" Then
nop
When db_type.i = "STR" Then
setup = setup"set "keyword"="Strip(inputrec)";"
When db_type.i = "BYTE" Then
setup = setup"set "keyword"="Strip(inputrec)";"
When db_type.i = "BOOL" Then
setup = setup"set "keyword"="!ValOnOff(Strip(inputrec))";"
When db_type.i = "INT" Then
setup = setup"set "keyword"="Strip(inputrec)";"
When db_type.i = "MLSTR" Then
If keyword = lastkeyword Then
setup = Strip(setup,'T',';')hex0A""Strip(Translate(inputrec,' ',','))";"
Else
setup = setup"set "keyword"="Strip(inputrec)";"
When db_type.i = "ENUM" Then
setup = setup"set "keyword"="Strip(inputrec)";"
Otherwise
Do
errormsg = "Invalid TYPE>"db_type.i
Call DISPLAYERR
End
End
If keyword = db_keyword.i Then
Leave
End
If i > db_num Then
setup = setup""keyword"="Strip(inputrec)";"
/* Do */
/* errormsg = "Invalid keyword>"keyword */
/* Call DISPLAYERR */
/* End */
End
return
PROCESS_RC:
/*
┌────────────────────────────────────────────────────────────────────┐
│ The following section will process the RCFILE. Any object or │
│ folder that is found in the RCFILE may be added to any other │
│ folder on the desktop. │
└────────────────────────────────────────────────────────────────────┘
*/
savelocation = location
/*
┌────────────────────────────────────────────────────────────────────┐
│ A line is read from the RCFILE. The line is scanned for the │
│ literal "PM_InstallObject" if found processing continues otherwise │
│ another line is read. If the line is processed then the data in │
│ the line will be used to build one object. This process continues │
│ until there are no more lines to be read. │
└────────────────────────────────────────────────────────────────────┘
*/
Do while Lines(rcfile) > 0
rcdata = LineIn(rcfile)
Parse Var rcdata '"'test'" ' rcdata
If test <> "PM_InstallObject" Then
Iterate
/*
┌────────────────────────────────────────────────────────────────────┐
│ The object's title, settings, class, and location are extraced, │
│ or parsed, from the line just read. If the object's class is not │
│ Mindex, WPProgram or WPFolder then the line is discarded and │
│ processing continues at the beginning of the DO loop where │
│ another record is read. │
└────────────────────────────────────────────────────────────────────┘
*/
Parse Var rcdata '"'titlclsloc'" ' rcdata
Parse Var rcdata '"'setup'" ' rcdata
Parse Var titlclsloc title';' titlclsloc
Parse Var titlclsloc classname';' titlclsloc
Select
When classname = "Mindex" then
Nop
When classname = "WPProgram" then
Nop
When classname = "WPFolder" then
Nop
Otherwise
Iterate
End
location = titlclsloc
setup = Strip(setup,'T','"')
/*
┌────────────────────────────────────────────────────────────────────┐
│ The OBJECTID will be extracted and removed from the setup string. │
└────────────────────────────────────────────────────────────────────┘
*/
objidbeg = Pos("OBJECTID=",setup)
if objidbeg > 0 then
do
objidend = Pos(';',setup,objidbeg) - 1
objidatend = 0
If objidend = -1 Then
do
objidend = Length(setup)
objidatend = 1
end
objid = SubStr(setup,objidbeg + 9,objidend - objidbeg - 8)
Select
When Length(setup) = Length(objid) + 9 Then
setup = ""
When objidbeg = 1 Then
setup = Right(setup,Length(setup) - Length(objid) - 10)
When objidatend = 1 Then
setup = Left(setup,Length(setup) - Length(objid) - 10)
Otherwise
setup = Left(setup,Length(setup) - objidbeg - 13)Right(setup,Length(setup) - objidend - 1)
End
End
/*
┌────────────────────────────────────────────────────────────────────┐
│ If the keyword COPYRCFOLDER is being processed then the only valid │
│ classes are "Mindex" or "WPProgram". If an invalid class is found │
│ then processing continues at the top of the do loop where another │
│ line is read. │
└────────────────────────────────────────────────────────────────────┘
*/
If copyrcobject <> "" then
Select
When classname = "Mindex" then
If objid <> '<'copyrcobject'>' then
Iterate
When classname = "WPProgram" then
If objid <> '<'copyrcobject'>' then
Iterate
Otherwise
Iterate
End
/*
┌────────────────────────────────────────────────────────────────────┐
│ If the keyword COPYRCOBJECT is being processed then the only valid │
│ classes are "Mindex", "WPProgram" or "WPFOLDER". If an invalid │
│ class is found then processing continues at the top of th do loop │
│ where another line is read. │
└────────────────────────────────────────────────────────────────────┘
*/
Else
Select
When classname = "Mindex" then
If location <> '<'copyrcfolder'>' then
Iterate
When classname = "WPProgram" then
If location <> '<'copyrcfolder'>' then
Iterate
When classname = "WPFolder" then
If objid <> '<'copyrcfolder'>' then
Iterate
Otherwise
Iterate
End
/*
┌────────────────────────────────────────────────────────────────────┐
│ The OBJECTID is given a new prefix and the object may be given a │
│ new location. │
└────────────────────────────────────────────────────────────────────┘
*/
objid = '<'copyrcnewprefix''SubStr(objid,Pos('_',objid))
objectid = "OBJECTID="objid";"
If classname = "Mindex" Then
If copyrcnewfolder = "" Then
location = savelocation
Else
Nop
Else
If classname = "WPFolder" Then
If copyrcnewfolder = "" Then
location = savelocation
Else
Iterate
Else
if SubStr(location,1,1) = '<' then
location = '<'copyrcnewprefix''SubStr(location,Pos('_',location))
If copyrcnewfolder <> "" Then
location = '<'copyrcnewfolder'>'
/*
┌────────────────────────────────────────────────────────────────────┐
│ The object is set as deletable and then the the PROCESS section is │
│ called to create the object. If a COPYRCOBJECT was being processed │
│ then the DO loop is terminated, however, if a COPYRCFOLDER is │
│ being processed then processing continues at the top of the DO │
│ loop where another line read. The entire RCFILE will be read for │
│ the objects that belong to this folder. │
└────────────────────────────────────────────────────────────────────┘
*/
setup = setup";NODELETE=NO"
Call PROCESS
If copyrcobject <> "" then
Leave
End
/*
┌────────────────────────────────────────────────────────────────────┐
│ The location variable is restored to its previous value and the │
│ other variables used are initialized. │
└────────────────────────────────────────────────────────────────────┘
*/
location = savelocation
retcode = stream(rcfile, 'c', 'close')
Call INITIALIZE
Return
EVALUATE_EXENAME:
/*
┌────────────────────────────────────────────────────────────────────┐
│ This section will search for the executable (.EXE, .COM, .BAT, │
│ .CMD) on all physical or logical drives. When found the original │
│ name is replaced by the fully qualified filename. If the name │
│ is an asterisk then this section is exited. │
└────────────────────────────────────────────────────────────────────┘
*/
If exename = "*" Then
return
/*
┌────────────────────────────────────────────────────────────────────┐
│ The second position of the name is checked for a colon. This │
│ indicates that the name is already fully qualified. │
└────────────────────────────────────────────────────────────────────┘
*/
If SubStr(FileSpec("drive",exename), 2, 1) = ":" Then
return
/*
┌────────────────────────────────────────────────────────────────────┐
│ The following sets which drives will be searched for executables. │
│ If an asterisk is in the DATABASE parameter SEARCHDRIVE then │
│ all drives will be searched. If the SEARCHDRIVE variable contains │
│ a drive letter then only that drive is searched, however if it is │
│ not a valid drive then all drives will be searched. │
└────────────────────────────────────────────────────────────────────┘
*/
drivesinuse = SysDriveMap('C:','USED')
If searchdrive <> '*' Then
If WordPos(searchdrive,drivesinuse) > 0 Then
drivesinuse = searchdrive
Say "Processing drives:" drivesinuse
/*
┌────────────────────────────────────────────────────────────────────┐
│ The following creates a table of fully qualified filenames based │
│ the executable name. Note that it is possible not to specify a │
│ drive letter and still specify an absolute or relative path for │
│ the executable. │
└────────────────────────────────────────────────────────────────────┘
*/
found.0 = 0
Do words(drivesinuse)
Call SysFileTree word(drivesinuse,1)'\'FileSpec("name",exename), 'file', 'SFO'
If file.0 > 0 Then
Do i=1 to file.0
found.0 = found.0 + 1
j = found.0
found.j = file.i
End
drivesinuse = Subword(drivesinuse,2)
End
/*
┌────────────────────────────────────────────────────────────────────┐
│ If the executable was not found a message is displayed and the │
│ section is exited. │
└────────────────────────────────────────────────────────────────────┘
*/
If found.0 = 0 Then
Do
errormsg = "The EXENAME="exename" was not found"
Call DISPLAYERR
abortind = 1
return
End
/*
┌────────────────────────────────────────────────────────────────────┐
│ The following will create another table of fully qualified file │
│ names. If the executable was specified with a partial path and │
│ the executable does exist along that path then those entries are │
│ written to the new table. │
└────────────────────────────────────────────────────────────────────┘
*/
selected.0 = 0
Do i=1 to found.0
If exename = Right(found.i,Length(exename)) Then
Do
selected.0 = selected.0 + 1
j = selected.0
selected.j = found.i
End
End
/*
┌────────────────────────────────────────────────────────────────────┐
│ If only one fully qualified name was found then replace the │
│ previous name with the fully quallified name and exit. │
└────────────────────────────────────────────────────────────────────┘
*/
If selected.0 = 1 Then
Do
exename = selected.1
return
End
/*
┌────────────────────────────────────────────────────────────────────┐
│ If the executable was found on a drive but not along the path │
│ specified then an error is displayed and processing continues. │
└────────────────────────────────────────────────────────────────────┘
*/
If selected.0 = 0 Then
Do
errormsg = "The EXENAME="exename" was not found but the executable" FileSpec("name",exename) "was!"
Call DISPLAYERR
End
/*
┌────────────────────────────────────────────────────────────────────┐
│ The executable was found on a drive and along the specified path. │
│ The original table that contains all the fully qualified names │
│ is replaced with the table was filtered by the absolute or │
│ relative path. │
└────────────────────────────────────────────────────────────────────┘
*/
If selected.0 > 0 Then
Do i=0 to selected.0
found.i = selected.i
End
/*
┌────────────────────────────────────────────────────────────────────┐
│ The fully qualified file names are displayed and the user is │
│ prompted to make a selection. The selection is validated. │
└────────────────────────────────────────────────────────────────────┘
*/
selected = 0
Do until selected = 1
Do i=1 to found.0
drive = FileSpec("drive",found.i)
path = Strip(FileSpec("path",found.i), "T", "\")
drivepath = drive""path
If i = 1 Then
Do
response = "The executable "exename" was found in multiple directories!"
Call DISPLAYRSP
response = "Select the appropriate directory or 0 to bypass:"
Call DISPLAYRSP
End
response = " "i"." drivepath
Call DISPLAYRSP
End
pull answer
If answer = 0 Then
Do
errormsg = "Entry aborted!"
Call DISPLAYERR
abortind = 1
return
End
If answer > 0 Then
If answer < found.0 + 1 Then
Do
response = "selected: " found.answer
Call DISPLAYRSP
exename = found.answer
selected = 1
End
End
return
PROCESS:
/*
┌────────────────────────────────────────────────────────────────────┐
│ This section determines if the object should be processed. │
└────────────────────────────────────────────────────────────────────┘
*/
If prefix <> '' Then
Do
bypassind = 0
If SubStr(objectid,10,Length(prefix)+1) <> '<'prefix Then
bypassind = bypassind + 1
If SubStr(location,1,Length(prefix)+1) <> '<'prefix Then
bypassind = bypassind + 1
If bypassind > 1 Then
return
End
If abortind = 1 Then
Do
abortind = 0
return
End
If title <> "" Then
Call MAKE_OBJECT
return
INITIALIZE:
/*
┌────────────────────────────────────────────────────────────────────┐
│ This section initializes most of the variables used to process an │
│ object. │
└────────────────────────────────────────────────────────────────────┘
*/
/* SysCreateObject variables */
classname = "WPProgram"
title = ""
setup = ""
duplicateflag = "U"
objectid = ""
exename = ""
progtype = ""
copyrcobject = ""
copyrcfolder = ""
/* miscellanoues variables */
exepath = ""
return
MAKE_OBJECT:
/*
┌────────────────────────────────────────────────────────────────────┐
│ This section processes the object, displays rather the process was │
│ successful or not, and logs the information to a file. │
└────────────────────────────────────────────────────────────────────┘
*/
objsetup = objectid""setup
RetCode = SysCreateObject(classname,,
title,,
location,,
objsetup,,
duplicateflag)
If retcode = 1 Then
retdesc = "Status: Successful"
Else
retdesc = "Status: Unsuccessful"
line1 = " "
line2 = Date() Time() "Classname: " classname
line3 = Date() Time() "Title: " title
line4 = Date() Time() "Location: " location
line5 = Date() Time() "Setup: " objsetup
line6 = Date() Time() "Duplicateflag: " duplicateflag
line7 = retdesc
say line1
say line2
say line3
say line4
say line5
say line6
say line7
rc = lineout(logfile, line1)
rc = lineout(logfile, line2)
rc = lineout(logfile, line3)
rc = lineout(logfile, line4)
rc = lineout(logfile, line5)
rc = lineout(logfile, line6)
rc = lineout(logfile, line7)
return
!ValOnOff:
/*
┌────────────────────────────────────────────────────────────────────┐
│ This function will accept a value of "ON" or 1 to return a value │
│ of 1 otherwise it will return a value of 0. │
│ Ex. x = ValOnOff("on") will set the value of x to 1. │
│ x = ValOnOff(1) will set the value of x to 1. │
│ x = ValOnOff("Off") will set the value of x to 0. │
│ x = ValOnOff(0) will set the value of x to 0. │
│ x = ValOnOff("xYz") will set the value of x to 0. │
└────────────────────────────────────────────────────────────────────┘
*/
parse upper arg ansonoff
Select
When substr(ansonoff, 1, 2) = 'ON' Then
return(1)
When substr(ansonoff, 1, 1) = '1' Then
return(1)
Otherwise
return(0)
End
return(0)
!ValYesNo:
/*
┌────────────────────────────────────────────────────────────────────┐
│ This function will accept a value of "YES" or 1 to return a value │
│ of 1 otherwise it will return a value of 0. │
│ Ex. x = ValYesNo("yes") will set the value of x to 1. │
│ x = ValYesNo(1) will set the value of x to 1. │
│ x = ValYesNo("no") will set the value of x to 0. │
│ x = ValYesNo(0) will set the value of x to 0. │
│ x = ValYesNo("xYz") will set the value of x to 0. │
└────────────────────────────────────────────────────────────────────┘
*/
parse upper arg ansyesno
Select
When substr(ansyesno, 1, 2) = 'YES' Then
return(1)
When substr(ansyesno, 1, 1) = '1' Then
return(1)
Otherwise
return(0)
End
return(0)
DISPLAYRESET:
/*
┌────────────────────────────────────────────────────────────────────┐
│ Reset the display to its default foreground and background colors. │
└────────────────────────────────────────────────────────────────────┘
*/
say "
"
return
DISPLAYRSP:
/*
┌────────────────────────────────────────────────────────────────────┐
│ This will display the value of the variable RESPONSE in yellow on │
│ a blue background. │
└────────────────────────────────────────────────────────────────────┘
*/
say "
"response"
"
line1 = " "
line2 = Date() Time() "Response: " response
rc = lineout(logfile, line1)
rc = lineout(logfile, line2)
return
DISPLAYERR:
/*
┌────────────────────────────────────────────────────────────────────┐
│ This will display the value of the variable ERRORMSG in white on a │
│ blue background. │
└────────────────────────────────────────────────────────────────────┘
*/
say "
"errormsg"
"
line1 = " "
line2 = Date() Time() "Error: " errormsg
rc = lineout(logfile, line1)
rc = lineout(logfile, line2)
return