home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
MNET10.ZIP
/
MakeNet.cmd
< prev
next >
Wrap
OS/2 REXX Batch file
|
1992-12-11
|
6KB
|
224 lines
/* MakeNet REXX procedure to build NET.CFG */
Ver = 'v1.01' /* Matthew Palcic, 11 Dec 92 */
ProgTitle = 'MakeNet 'Ver', Copyright 1992, Matthew Palcic'
parse arg DefFileSpec
address cmd
env='OS2ENVIRONMENT' /* Access the OS2 environment */
CltDrv=value('TargetDrive',,env) /* Gets drive letter from OS2 */
if CltDrv = '' then CltDrv = 'C:' /* If the TargetDrive environment
variable is empty the default
drive is C: */
NetCfgFile = CltDrv'\NET.CFG'
RedirNull = ' 1>>NUL: 2>>NUL:'
call SetupAnsi
'@ECHO OFF'; say Normal; 'CLS'
Say '';Say Bold||ProgTitle||NoBold
if DefFileSpec = '' then
call TellParameters
say
call ParseDefFile DefFileSpec
call Cleanup
say; say 'Finished generating 'NetCfgFile
exit
ParseDefFile: arg DefFile
say; say 'Processing: 'DefFile
call BackupFile(NetCfgFile)
call ZapFile(NetCfgFile)
call ShowDrivers(DefFile); say
SelDrv = GetDriverNum()
say 'Selected Driver: 'Drivers.SelDrv' [line 'DrvLine.SelDrv']'; say
do while lines(DefFile)
DefLine = linein(DefFile)
parse value DefLine with Cmd Rest
Cmd = translate(Cmd)
select
when SubStr(DefLine,1,1) = ';' then
nop /* Comment */
when Cmd = 'DRIVER' then do
Title = Strip(Rest)
drop Port Memory Int
Done = 0
if Title = Drivers.SelDrv then
rc = CfgPut('Link Driver 'Title)
do while (Done = 0) /* Process the indented driver lines */
ObjLine = linein(DefFile)
parse value ObjLine with Cmd Rest
Cmd = Strip(Translate(Cmd))
select
when \Lines(DefFile) then
Done = 1 /* No more lines in file */
when Length(ObjLine) = 0 then
Done = 1 /* First empty line ends driver */
otherwise
nop
end
if Title = Drivers.SelDrv then do /* This is the driver we want */
select
when SubStr(ObjLine,1,1) = ';' then
nop /* Comment */
when Cmd = 'PORT' then do
parse upper value Strip(Rest) with Port
Port = ReqHexInfo('I/O Port',Port)
if Port \= '' then rc = CfgPut(' Port 'Port)
end
when Cmd = 'MEM' then do
parse upper value Strip(Rest) with Memory
Memory = ReqHexInfo('Memory Address',Memory)
if Memory \= '' then rc = CfgPut(' Mem 'Memory)
end
when Cmd = 'INT' then do
parse upper value Strip(Rest) with Int
Int = ReqHexInfo('Interrupt',Int)
if Int \= '' then rc = CfgPut(' Int 'Int)
end
when Cmd = 'SAY' then
call ScrPut(Rest)
when Cmd = 'PUT' then
call CfgPut(' 'Rest)
when Cmd = 'WARN' then
call ScrPut(BrightRed||Title': 'Rest||Normal)
/* Add your own command like this:
when Cmd = 'MYNEWCMD' then
DoThis
*/
otherwise
nop
end
end
end
end
when Cmd = 'SAY' then
call ScrPut(Rest)
when Cmd = 'PUT' then
call CfgPut(Rest)
when Cmd = 'WARN' then
rc = ScrPut(BrightRed||Rest||Normal)
/* Add your own commands like this:
when Cmd = 'MYNEWCMD' then
DoThis
*/
otherwise /* Unknown command */
nop
end /* select */
end /* do */
return /* Done with ParseDefFile */
SetupAnsi:
Bold = '
'
NoBold = '
'
BrightRed = '
'
Cyan = '
'
BrightCyan = '
'
Normal = NoBold
return
WipePrompt:
call charout ,'A'
return
ShowDrivers:
FileLines = 0
x = 0
parse arg DrvDef
say; say 'Drivers:'
call ResetFile(DrvDef)
do while lines(DrvDef) /* Do until end of file */
it = linein(DrvDef) /* Read first line */
FileLines = FileLines + 1
uit = translate(it)
if pos('DRIVER', uit) = 1 then do
x = x + 1
parse var uit junk DrvName
Drivers.x = DrvName
DrvLine.x = FileLines
Drivers.0 = x
DrvLine.0 = x
say ' 'Bold||x||NoBold' 'DrvName
end
end
call ResetFile(DrvDef)
return
GetDriverNum:
rx = 0
do while ((rx < 1) | (rx > Drivers.0))
call charout ,'Select driver number: '
pull rx
call WipePrompt
if verify(rx,'0123456789')\=0 then
rx = Drivers.0 + 1
end
return rx
ResetFile: procedure
parse arg FileName
rc = linein(FileName,1,0)
return
TellParameters:
say; say ' Syntax: MakeNet netfile'; say
say ' You must pass a .NET file to process.'
say ' Example: MakeNet D:\KeepSafe\Drivers.Net'
call CleanUp
exit
return
ReqHexInfo: procedure
say
Prompt = ARG(1); Contents = ARG(2)
say 'Default 'Prompt': 'Contents
UserValue = 'junk'
do until (verify(UserValue,'0123456789ABCDEF')=0) | (UserValue = '')
call charout ,'Enter new 'Prompt' or [Enter] for the default: '
pull UserValue
call WipePrompt
end
if UserValue = '' then
UserValue = Contents
do 2
call WipePrompt
end /* do */
say Prompt': 'UserValue
return UserValue
CfgPut: procedure expose NetCfgFile
Parm = ARG(1)
rc = lineout(NetCfgFile,Parm)
return rc
BackupFile: procedure expose RedirNull
Parm = ARG(1)
BackExt = '.bak'
DotPos = LastPos('.',Parm)
if DotPos = 0 then
ParmB = Parm||BackExt
else
ParmB = OverLay(BackExt,Parm,DotPos)
'copy 'parm' 'parmb||RedirNull
say; say; say Parm 'backed up to 'ParmB;
return
ZapFile: procedure expose RedirNull
Parm = ARG(1)
'del 'parm||RedirNull
return
ScrPut:
Parm = ARG(1)
say Parm
return
Cleanup:
nop
return