home *** CD-ROM | disk | FTP | other *** search
/ Aminet 10 / aminetcdnumber101996.iso / Aminet / util / rexx / ScionRexx.lha / SetDefaults.rexx < prev    next >
OS/2 REXX Batch file  |  1995-10-31  |  8KB  |  190 lines

  1. /****************************************************************************
  2.  *                                                                          *
  3.  *                                                                          *
  4.  * $VER: SetDefaults.rexx 1.01 (31 Oct 1995)
  5.  *                                                                          *
  6.  *                      Written by Freddy Ariës                             *
  7.  *   Address: Lindeboomweg 7, NL-7135 KE Harreveld, The Netherlands.        *
  8.  *                                                                          *
  9.  * Instead of having to edit my scripts every time I release an update,     *
  10.  * to change the settings to your own liking, you can now just run this     *
  11.  * script once, and all the scripts will use the created prefs file.        *
  12.  * This means that in the future, you will never again have to do any       *
  13.  * editing after an update !!!                                              *
  14.  *                                                                          *
  15.  * Note to other ARexx programmers: feel free to use the preferences file   *
  16.  * (ENV:Scion/ScionRexx.prefs) for your own purposes. There are only a few  *
  17.  * things you have to take into account:                                    *
  18.  * 1. Every line has to start with a unique keyword                         *
  19.  *    (keywords currently in use: [NO]USEREQ, [NO]USEPROGRESS, PUBSCREEN    *
  20.  *     NOTES, LINEWIDTH and PAGESIZE)                                       *
  21.  *    So if you want to put all your settings on one single line, fine,     *
  22.  *    but please make sure the first word of the line is not one of the     *
  23.  *    above!                                                                *
  24.  * 2. Please write the required lines of code for reading and writing your  *
  25.  *    settings (keywords AND options) from/to the file, and mail them to me,*
  26.  *    for inclusion in this script. If you do not do this, your settings    *
  27.  *    will be erased from the prefs file when the user uses this script to  *
  28.  *    modify the existing settings.                                         *
  29.  * 3. If you put a save option in your own script, make sure it does not    *
  30.  *    modify or erase any of the other lines that are in the file.          *
  31.  *    Only this script is allowed to do that.                               *
  32.  *                                                                          *
  33.  * IMPORTANT: This script is FREEWARE, NOT Public Domain. You can use and   *
  34.  *   distribute it freely, ie. I don't ask any money for it, but you        *
  35.  *   are not allowed to modify it. To avoid having different versions       *
  36.  *   of this script floating around, each recognizing different keywords,   *
  37.  *   (see points 1-3 above), I am the only one allowed to change it.        *
  38.  *                                                                          *
  39.  ****************************************************************************/
  40.  
  41. options failat 20; options prompt '> '
  42.  
  43. versionstr = "1.01"
  44.  
  45. usereq = 1; prgrs = 1; notesdir = ""
  46. plwidth = 78; pscr = "SCIONGEN"
  47. pgsize = 0
  48.  
  49. NL = '0A'x; CLR = '0C'x
  50.  
  51. /* HERE THE PREFERENCES FILE IS READ,
  52.  * AND AN ATTEMPT IS MADE TO RECOGNIZE ALL OF THE LINES IN IT.
  53.  */
  54.  
  55. if open(pfile, 'ENV:Scion/ScionRexx.prefs', 'r') then do
  56.   do while ~eof(pfile)
  57.     inln = readln(pfile)
  58.     if inln ~= "" then do
  59.       wstr = upper(word(inln, 1))
  60.       if wstr = "NOTES" then
  61.         notesdir = strip(delstr(inln, 1, length(wstr)), 'b', ' "')
  62.       else if wstr = "USEREQ" then
  63.         usereq = 1
  64.       else if wstr = "NOUSEREQ" then
  65.         usereq = 0
  66.       else if wstr = "PROGRESS" then
  67.         prgrs = 1
  68.       else if wstr = "NOPROGRESS" then
  69.         prgrs = 0
  70.       else if wstr = "PUBSCREEN" then
  71.         pscr = strip(delstr(inln, 1, length(wstr)), 'b', ' "')
  72.       else if wstr = "LINEWIDTH" then do
  73.         wstr = word(inln, 2)
  74.         if datatype(wstr, 'w') then plwidth = wstr
  75.       end
  76.       else if wstr = "PAGESIZE" then do
  77.         wstr = word(inln, 2)
  78.         if datatype(wstr, 'w') then pgsize = wstr
  79.       end
  80.     end
  81.   end
  82.   close(pfile)
  83. end
  84.  
  85. if notesdir ~= "" then do
  86.   wstr = right(notesdir, 1)
  87.   if wstr ~= '/' & wstr ~= ':' then notesdir = notesdir||'/'
  88. end
  89. if pscr = "" then pscr = "SCIONGEN"
  90.  
  91. say "**************************************************************"
  92. say "***         SetDefaults v"||versionstr||" by Freddy Ariës :            ***"
  93. say "***  Set or change the default values for several of the   ***"
  94. say "***  ARexx scripts supplied with this version of Scion.    ***"
  95. say "**************************************************************"
  96. say NL||"Current settings:"||NL
  97. do until instr = '0'
  98.   if usereq then
  99.     say " <1> Use REQUESTERS for screen I/O:         <ON>"
  100.   else
  101.     say " <1> Use REQUESTERS for screen I/O:         <OFF>"
  102.   if prgrs then
  103.     say " <2> Display PROGRESS requester:            <ON>"
  104.   else
  105.     say " <2> Display PROGRESS requester:            <OFF>"
  106.   say " <3> Default PUBLIC SCREEN for screen I/O:  "||PSCR
  107.   if notesdir = "" then
  108.     say ' <4> Directory for NOTE files:              <NONE> (= program should ask)'
  109.   else
  110.     say ' <4> Directory for NOTE files: "'||notesdir||'"'
  111.   say " <5> LINEWIDTH (printer/file I/O):          "||plwidth
  112.   if pgsize = 0 then
  113.     say " <6> LINES PER PAGE (printer/file I/O):     <UNLIMITED>"
  114.   else
  115.     say " <6> LINES PER PAGE (printer/file I/O):     "||pgsize
  116.   if prgrs & ~usereq then say NL||"WARNING: REQUESTERS OFF and PROGRESS ON makes no sense!"
  117.   say NL||"Enter 1-6 to change one of the settings, or 0 to save and quit."
  118.   pull instr
  119.   if instr = '1' then
  120.     usereq = ~usereq
  121.   else if instr = '2' then
  122.     prgrs = ~prgrs
  123.   else if instr = '3' then do
  124.     say 'Enter name of public screen to use (eg. SCIONGEN or WORKBENCH)'
  125.     pull inp$
  126.     pscr = strip(inp$, 'b', ' "')
  127.     if pscr = "" then pscr = "SCIONGEN"
  128.   end
  129.   else if instr = '4' then do
  130.     say 'In which directory do you keep your NOTE files for Scion?'
  131.     say "This string MUST end with ':' or '/', eg: WORK:Scion/Notes/"
  132.     say "If you want the program to ask for a directory every time,"
  133.     say "simply press <return>."
  134.     pull inp$
  135.     notesdir = strip(inp$, 'b', ' "')
  136.     if notesdir ~= "" then do
  137.       wstr = right(notesdir, 1)
  138.       if wstr ~= '/' & wstr ~= ':' then notesdir = notesdir||'/'
  139.     end
  140.   end
  141.   else if instr = '5' then do
  142.     say 'Enter linewidth for printer output.'
  143.     pull inp
  144.     if datatype(inp, 'w') then plwidth = inp
  145.   end
  146.   else if instr = '6' then do
  147.     say 'Enter pagesize (number of lines per page) for printer output,'
  148.     say 'or 0 for umlimited: '
  149.     pull inp
  150.     if datatype(inp, 'w') then pgsize = inp
  151.   end
  152.   say CLR
  153. end
  154.  
  155. /* NOW WRITE THE PREFERENCES FILE */
  156. if ~exists('ENV:Scion') then
  157.   address command 'makedir ENV:Scion'
  158. if ~exists('ENV:Scion') then
  159.   EndString("ERROR: Unable to create ENV:Scion directory")
  160. if open(pfile, 'ENV:Scion/ScionRexx.prefs', 'w') then do
  161.   if usereq then
  162.     writeln(pfile, 'USEREQ')
  163.   else
  164.     writeln(pfile, 'NOUSEREQ')
  165.   if prgrs then
  166.     writeln(pfile, 'PROGRESS')
  167.   else
  168.     writeln(pfile, 'NOPROGRESS')
  169.   writeln(pfile, 'PUBSCREEN '||pscr)
  170.   if notesdir ~= "" then
  171.     writeln(pfile, 'NOTES '||notesdir)
  172.   writeln(pfile, 'LINEWIDTH '||plwidth)
  173.   writeln(pfile, 'PAGESIZE '||pgsize)
  174.   close(pfile)
  175.   if ~exists('ENVARC:Scion') then
  176.     address command 'makedir ENVARC:Scion'
  177.   if exists('ENVARC:Scion') then
  178.     address command 'copy ENV:Scion/ScionRexx.prefs ENVARC:Scion/'
  179.   EndString("Done.")
  180. end
  181. else
  182.   EndString("ERROR: Unable to create file ENV:Scion/ScionRexx.prefs")
  183.  
  184. EXIT
  185.  
  186. EndString: PROCEDURE
  187. parse arg str
  188.   say str
  189. EXIT
  190.