home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 10
/
aminetcdnumber101996.iso
/
Aminet
/
util
/
rexx
/
ScionRexx.lha
/
SetDefaults.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1995-10-31
|
8KB
|
190 lines
/****************************************************************************
* *
* *
* $VER: SetDefaults.rexx 1.01 (31 Oct 1995)
* *
* Written by Freddy Ariës *
* Address: Lindeboomweg 7, NL-7135 KE Harreveld, The Netherlands. *
* *
* Instead of having to edit my scripts every time I release an update, *
* to change the settings to your own liking, you can now just run this *
* script once, and all the scripts will use the created prefs file. *
* This means that in the future, you will never again have to do any *
* editing after an update !!! *
* *
* Note to other ARexx programmers: feel free to use the preferences file *
* (ENV:Scion/ScionRexx.prefs) for your own purposes. There are only a few *
* things you have to take into account: *
* 1. Every line has to start with a unique keyword *
* (keywords currently in use: [NO]USEREQ, [NO]USEPROGRESS, PUBSCREEN *
* NOTES, LINEWIDTH and PAGESIZE) *
* So if you want to put all your settings on one single line, fine, *
* but please make sure the first word of the line is not one of the *
* above! *
* 2. Please write the required lines of code for reading and writing your *
* settings (keywords AND options) from/to the file, and mail them to me,*
* for inclusion in this script. If you do not do this, your settings *
* will be erased from the prefs file when the user uses this script to *
* modify the existing settings. *
* 3. If you put a save option in your own script, make sure it does not *
* modify or erase any of the other lines that are in the file. *
* Only this script is allowed to do that. *
* *
* IMPORTANT: This script is FREEWARE, NOT Public Domain. You can use and *
* distribute it freely, ie. I don't ask any money for it, but you *
* are not allowed to modify it. To avoid having different versions *
* of this script floating around, each recognizing different keywords, *
* (see points 1-3 above), I am the only one allowed to change it. *
* *
****************************************************************************/
options failat 20; options prompt '> '
versionstr = "1.01"
usereq = 1; prgrs = 1; notesdir = ""
plwidth = 78; pscr = "SCIONGEN"
pgsize = 0
NL = '0A'x; CLR = '0C'x
/* HERE THE PREFERENCES FILE IS READ,
* AND AN ATTEMPT IS MADE TO RECOGNIZE ALL OF THE LINES IN IT.
*/
if open(pfile, 'ENV:Scion/ScionRexx.prefs', 'r') then do
do while ~eof(pfile)
inln = readln(pfile)
if inln ~= "" then do
wstr = upper(word(inln, 1))
if wstr = "NOTES" then
notesdir = strip(delstr(inln, 1, length(wstr)), 'b', ' "')
else if wstr = "USEREQ" then
usereq = 1
else if wstr = "NOUSEREQ" then
usereq = 0
else if wstr = "PROGRESS" then
prgrs = 1
else if wstr = "NOPROGRESS" then
prgrs = 0
else if wstr = "PUBSCREEN" then
pscr = strip(delstr(inln, 1, length(wstr)), 'b', ' "')
else if wstr = "LINEWIDTH" then do
wstr = word(inln, 2)
if datatype(wstr, 'w') then plwidth = wstr
end
else if wstr = "PAGESIZE" then do
wstr = word(inln, 2)
if datatype(wstr, 'w') then pgsize = wstr
end
end
end
close(pfile)
end
if notesdir ~= "" then do
wstr = right(notesdir, 1)
if wstr ~= '/' & wstr ~= ':' then notesdir = notesdir||'/'
end
if pscr = "" then pscr = "SCIONGEN"
say "**************************************************************"
say "*** SetDefaults v"||versionstr||" by Freddy Ariës : ***"
say "*** Set or change the default values for several of the ***"
say "*** ARexx scripts supplied with this version of Scion. ***"
say "**************************************************************"
say NL||"Current settings:"||NL
do until instr = '0'
if usereq then
say " <1> Use REQUESTERS for screen I/O: <ON>"
else
say " <1> Use REQUESTERS for screen I/O: <OFF>"
if prgrs then
say " <2> Display PROGRESS requester: <ON>"
else
say " <2> Display PROGRESS requester: <OFF>"
say " <3> Default PUBLIC SCREEN for screen I/O: "||PSCR
if notesdir = "" then
say ' <4> Directory for NOTE files: <NONE> (= program should ask)'
else
say ' <4> Directory for NOTE files: "'||notesdir||'"'
say " <5> LINEWIDTH (printer/file I/O): "||plwidth
if pgsize = 0 then
say " <6> LINES PER PAGE (printer/file I/O): <UNLIMITED>"
else
say " <6> LINES PER PAGE (printer/file I/O): "||pgsize
if prgrs & ~usereq then say NL||"WARNING: REQUESTERS OFF and PROGRESS ON makes no sense!"
say NL||"Enter 1-6 to change one of the settings, or 0 to save and quit."
pull instr
if instr = '1' then
usereq = ~usereq
else if instr = '2' then
prgrs = ~prgrs
else if instr = '3' then do
say 'Enter name of public screen to use (eg. SCIONGEN or WORKBENCH)'
pull inp$
pscr = strip(inp$, 'b', ' "')
if pscr = "" then pscr = "SCIONGEN"
end
else if instr = '4' then do
say 'In which directory do you keep your NOTE files for Scion?'
say "This string MUST end with ':' or '/', eg: WORK:Scion/Notes/"
say "If you want the program to ask for a directory every time,"
say "simply press <return>."
pull inp$
notesdir = strip(inp$, 'b', ' "')
if notesdir ~= "" then do
wstr = right(notesdir, 1)
if wstr ~= '/' & wstr ~= ':' then notesdir = notesdir||'/'
end
end
else if instr = '5' then do
say 'Enter linewidth for printer output.'
pull inp
if datatype(inp, 'w') then plwidth = inp
end
else if instr = '6' then do
say 'Enter pagesize (number of lines per page) for printer output,'
say 'or 0 for umlimited: '
pull inp
if datatype(inp, 'w') then pgsize = inp
end
say CLR
end
/* NOW WRITE THE PREFERENCES FILE */
if ~exists('ENV:Scion') then
address command 'makedir ENV:Scion'
if ~exists('ENV:Scion') then
EndString("ERROR: Unable to create ENV:Scion directory")
if open(pfile, 'ENV:Scion/ScionRexx.prefs', 'w') then do
if usereq then
writeln(pfile, 'USEREQ')
else
writeln(pfile, 'NOUSEREQ')
if prgrs then
writeln(pfile, 'PROGRESS')
else
writeln(pfile, 'NOPROGRESS')
writeln(pfile, 'PUBSCREEN '||pscr)
if notesdir ~= "" then
writeln(pfile, 'NOTES '||notesdir)
writeln(pfile, 'LINEWIDTH '||plwidth)
writeln(pfile, 'PAGESIZE '||pgsize)
close(pfile)
if ~exists('ENVARC:Scion') then
address command 'makedir ENVARC:Scion'
if exists('ENVARC:Scion') then
address command 'copy ENV:Scion/ScionRexx.prefs ENVARC:Scion/'
EndString("Done.")
end
else
EndString("ERROR: Unable to create file ENV:Scion/ScionRexx.prefs")
EXIT
EndString: PROCEDURE
parse arg str
say str
EXIT