home *** CD-ROM | disk | FTP | other *** search
/ Aminet 10 / aminetcdnumber101996.iso / Aminet / util / rexx / ScionRexx.lha / Help.rexx < prev    next >
OS/2 REXX Batch file  |  1995-11-17  |  6KB  |  196 lines

  1. /****************************************************************************
  2.  *                                                                          *
  3.  * $VER: Help 1.13 (28 Oct 1995)
  4.  *                                                                          *
  5.  *       Written by Freddy Ariës, with modifications by Robbie Akins        *
  6.  *                                                                          *
  7.  * Just a simple menu, for those who can't remember under which function    *
  8.  * key they have stored a certain function.                                 *
  9.  *                                                                          *
  10.  * This script will output a requester on the Scion window, in which it     *
  11.  * will display the current settings of Scion's function keys.              *
  12.  * It requires a version of Scion Genealogist >= 4.04.                      *
  13.  *                                                                          *
  14.  * This script uses (by default) the rexxreqtools.library (which requires   *
  15.  * a version of reqtools larger than 2.0 and rexxsyslib.library)            *
  16.  * If you do not have these, run SetDefaults.rexx to change the settings.   *
  17.  *                                                                          *
  18.  * For this script to be of any use to you, you will have to add the        *
  19.  * Help.rexx command to the list of function keys that you have set in      *
  20.  * the ScionPrefs program (eg. under F1 or F10).                            *
  21.  *                                                                          *
  22.  * DONE:                                                                    *
  23.  *  - added "stripstring" option, and handling of long results              *
  24.  *    (done by Robbie Akins)                                                *
  25.  *  - enhanced stripstring options                                          *
  26.  *  - now uses preference file for default settings                         *
  27.  *                                                                          *
  28.  ****************************************************************************/
  29.  
  30. options results
  31.  
  32. versionstr = "1.13"
  33.  
  34. /* Don't change the settings here! Run SetDefaults.rexx instead! */
  35. NL = '0A'x
  36. PSCR = 'SCIONGEN'
  37. usereq = 1
  38.  
  39. scrdev = stdout; scrname = "CON:0//639//Scion Output/AUTO/SCREEN"
  40.  
  41. /* stripstring: 1 = strip directory path from string, 0 = don't strip */
  42. /* Feel free to change _these_ settings to your own liking */
  43. stripstring.1 = 1
  44. stripstring.2 = 1
  45. stripstring.3 = 1
  46. stripstring.4 = 1
  47. stripstring.5 = 1
  48. stripstring.6 = 1
  49. stripstring.7 = 1
  50. stripstring.8 = 1
  51. stripstring.9 = 1
  52. stripstring.10 = 1
  53.  
  54. /* read preferences file */
  55.  
  56. if open(pfile, 'ENV:Scion/ScionRexx.prefs', 'r') then do
  57.   do while ~eof(pfile)
  58.     inln = readln(pfile)
  59.     if inln ~= "" then do
  60.       wstr = upper(word(inln, 1))
  61.       if wstr = "USEREQ" then
  62.         usereq = 1
  63.       else if wstr = "NOUSEREQ" then
  64.         usereq = 0
  65.       else if wstr = "PUBSCREEN" then
  66.         pscr = strip(delstr(inln, 1, length(wstr)), 'b', ' "')
  67.     end
  68.   end
  69.   close(pfile)
  70. end
  71.  
  72. if pscr = "" | (pscr ~= "WORKBENCH" & ~show('p', pscr)) then
  73.   pscr = "SCIONGEN"
  74. scrname = scrname||pscr
  75.  
  76. if ~show('l','rexxarplib.library') then do
  77.   if exists('libs:rexxarplib.library') then
  78.     call addlib('rexxarplib.library',0,-30,0)
  79. end
  80.  
  81. screentofront(pscr)
  82.  
  83. if ~show('l','rexxreqtools.library') then do
  84.   if exists('libs:rexxreqtools.library') then
  85.     call addlib('rexxreqtools.library',0,-30,0)
  86.   else do
  87.     Tell("Unable to open rexxreqtools.library")
  88.     EXIT
  89.   end
  90. end
  91.  
  92. /* Originally stolen from Peter Billing - thanks Peter ;-) */
  93. if ~show('P','SCIONGEN') then do
  94.   EndString('I am sorry to say that the SCION Genealogist' || NL ||,
  95.     'database is not available. Please start the' || NL ||,
  96.     'SCION program BEFORE using this script!')
  97. end
  98.  
  99. myport = "SCIONGEN"
  100. address value myport
  101.  
  102. /*
  103.  * Now let's get funky... (get the current function key settings) ;-)
  104.  */
  105.  
  106. do i=1 to 10
  107.   GETFUNKEY i
  108.   fun.i = TruncString(StripPath(RESULT, i))
  109. end
  110.  
  111. if usereq then do
  112.   rtn = rtezrequest('Current Scion Function Keys: '||NL||,
  113.       NL||' F1  = '||fun.1||,
  114.       NL||' F2  = '||fun.2||,
  115.       NL||' F3  = '||fun.3||,
  116.       NL||' F4  = '||fun.4||,
  117.       NL||' F5  = '||fun.5||,
  118.       NL||' F6  = '||fun.6||,
  119.       NL||' F7  = '||fun.7||,
  120.       NL||' F8  = '||fun.8||,
  121.       NL||' F9  = '||fun.9||,
  122.       NL||' F10 = '||fun.10||,
  123.       '','_Ok','Help v'||versionstr||' by F.Ariës & R.Akins','rt_pubscrname = '||PSCR)
  124. end
  125. else do
  126.   if pscr ~= "WORKBENCH" then do
  127.     scrdev = 'SCNHLPSCR'
  128.     if ~open(scrdev, scrname, 'w') then scrdev = stdout
  129.   end
  130.   Tell('*** Help v'||versionstr||' by F. Ariës & R. Akins ***')
  131.   Tell(' Current Scion Function Keys: ')
  132.   Tell('  F1  = '||fun.1)
  133.   Tell('  F2  = '||fun.2)
  134.   Tell('  F3  = '||fun.3)
  135.   Tell('  F4  = '||fun.4)
  136.   Tell('  F5  = '||fun.5)
  137.   Tell('  F6  = '||fun.6)
  138.   Tell('  F7  = '||fun.7)
  139.   Tell('  F8  = '||fun.8)
  140.   Tell('  F9  = '||fun.9)
  141.   Tell('  F10 = '||fun.10)
  142.   if scrdev ~= stdout then do
  143.     Tell(NL||"Press <return> to exit.")
  144.     readln(scrdev)
  145.     close(scrdev)
  146.   end
  147. end
  148.  
  149. EXIT
  150.  
  151. EndString: PROCEDURE EXPOSE usereq pscr scrdev
  152. parse arg str
  153.   if usereq then
  154.     rtezrequest(str,'E_xit','Help Message:','rt_pubscrname = '||pscr)
  155.   else
  156.     Tell("ERROR: "||str)
  157. EXIT
  158.  
  159. /*
  160.  * Procedure to strip the directory path from the string.
  161.  * It will cut off the entire left part of the string, until (and including)
  162.  * the path name, only leaving the filename.
  163.  * If you don't want the path to be left off, use the stripstring flags
  164.  */
  165. StripPath: PROCEDURE EXPOSE stripstring.
  166. parse arg str, ix
  167. if stripstring.ix then /* test by Robbie Akins */
  168. do
  169.   p = lastpos('/', str)
  170.   if p > 0 then ret1 = delstr(str,1,p)
  171.   else ret1 = str
  172.   p = lastpos(':', ret1)
  173.   if p > 0 then retstr = delstr(ret1,1,p)
  174.   else retstr = ret1
  175. end
  176. else
  177.   retstr = str
  178. return retstr
  179.  
  180. /*
  181.  * Procedure to truncate long strings and add ellipsis (...) at the end
  182.  * Written by Robbie Akins
  183.  */
  184. TruncString: PROCEDURE
  185. parse arg trstr
  186. if length(trstr) > 60 then
  187.   rtnstr = trim(left(trstr, 60))||"..."
  188. else
  189.   rtnstr = trstr
  190. return rtnstr
  191.  
  192. Tell: PROCEDURE EXPOSE scrdev
  193. parse arg str
  194.   writeln(scrdev, str)
  195. return 0
  196.