#! /home/xed/msrexx

/*
 * ahelp: calls the Acrobat on-line help $xhome/help/help.pdf
 */

signal on novalue
option setenv mixed

arch = arch()

sep_path = ':'
sep_dir  = '/'
mod = 'acroread'

select
 when arch = 'sparc' | arch = 'sgi' then
                          dir = '/opt/Acrobat3/bin'
 when arch = 'sun4'  then dir = '/usr/Acrobat3/bin'
 when arch = 'ibm'   then dir = '/usr/lpp/Acrobat3/bin'
 when arch = 'hp'    then
  { a = `'uname -a'`
      /* HP-UX H B.10.10 A 9000/710 2002648946 two-user license */
    parse var a '.' rel ' '
    rel = rel[1:2]
    if rel >= 10 then
       dir = '/opt/Acrobat3/bin'
    else
       dir = '/usr/Acrobat3/bin'
  }
 when arch = 'alpha' then dir ='/usr/local/Acrobat3/bin'
 when arch = 'wnt'   then
  { dir      = 'C:\Acrobat3\Reader'
    sep_path = ';'
    mod      = 'AcroRd32.exe'
    sep_dir  = '\'
  }

 otherwise dir = '/usr/local/Acrobat3/bin'
end

bin = dir||sep_dir||mod

if ~state(bin) then
 { a  = $PATH
   nb = ''
   do while a ~= ''
      parse var a ndir (sep_path) a
      nb = ndir||sep_dir||mod
      if state(nb) then leave
   end

   if arch = 'wnt' & ~state(nb) then
    { wh = registry_get("HKEY_CLASSES_ROOT", "AcroExch.Document\DefaultIcon", "")
      /* --> "C:\Acrobat3\Reader\AcroRd32.exe,1 " */
      if wh ~= '' then
       { parse var wh found '.exe' .
         found = found'.exe'
         if found ~= '.exe' & state(found) then nb = found
       }
    }

   if ~state(nb) then
    {
      call display , 1, "Exit", ,,
         "Acrobat Reader Version 3 or greater must be installed to display",,
         "the SEDIT-S/REXX on-line help.",,
         ,,
         "The usual location is: " dir,,
         ,,
         "You can down-load Adobe Acrobat Reader from:",,
         ,,
         '        http://www.adobe.com/acrobat',,
         ,,
         "If Acrobat is installed on another directory, update your PATH",,
         "with this directory and restart this program."
      exit
    }
   else bin = nb
 }

if arch = 'wnt' then '"'bin'"'  '"'xhome()'\help\help.pdf"&'
else                 bin xhome()'/help/help.pdf&'
