home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rdebug21.zip / RHYPERTX.KEX < prev    next >
Text File  |  1993-03-25  |  9KB  |  350 lines

  1. /*H* RHYPERTX.KEX 01-09-93 12:04 */
  2.  Parse source sys .
  3.  if      sys='OS/2'  then sys='OS2'
  4.  else if sys='PCDOS' then sys='DOS'
  5.  if (sys='DOS') + (sys='OS2')>0 then pc?=1
  6.  trace o?r  /*T*/
  7.  me='rHYPERTX'
  8.  If arg(1)=?  Then Exit tell(me)
  9.  If arg(1)='' Then Exit tell(me)
  10.  arg key '/'origin
  11.  /*
  12.  if key then use it rather than word at cursor
  13.  if shortform (Xnb) then call x.rex to get fullname
  14.  if key contains a period then call up a file
  15.   if ft=EXE COM or * then search key in system.hlp
  16.   else if path coded edit file directly
  17.        else search for file on c then d drives
  18.  if key contains two words & is on cms then call up a file
  19.  if key contains two words & is on pc then call findkey on two words
  20.  for selected filetypes
  21.    if special keys then import a template,
  22.    else lookup key by language type
  23.    otherwise if not found call findkey
  24.  */
  25.  call initialize
  26.  Select
  27.    when origin='RDEBUG' then nop
  28.    when words(key)=2&pc?=0 then call locate_file
  29.    when pos('.',key)>0 then call locate_file
  30.    When ft='REX'   Then call language_rexx
  31.    When ft='KEX'   Then call language_xedit
  32.    When ft='KML'   Then call language_kexx
  33.    When ft='BOK'   Then call note_book
  34.    When ft='LOG'   Then call note_book
  35.    When ft='BAT'   Then call 'hyperbat' key
  36.    When ft='C'     Then call 'hyperc' key
  37.    Otherwise call findkey
  38.  End
  39.  if origin<>'RDEBUG' then if newfile?=0 then 'LOC :'here
  40.  c 'SET LINEND' linend.1
  41.  c 'SET msgm' MSGMODE.1
  42.  Exit lkey src
  43.  
  44.  INITIALIZE:
  45.  if pc? then c=''
  46.  c 'EXTRACT /FT/CURSOR/LINEND/LINE/MSGM/curline/autosave'
  47.  c 'SET LINEND OFF'
  48.  c 'SET msgm OFF'
  49.  c 'set point .h off'
  50.  c 'set point .h'
  51.  case='MIXED IGNORE'
  52.  Parse Value ftype.1 line.1 0 2 With ft here newfile? src
  53.  if pc? then do
  54.    c 'extract /fileid'
  55.    if origin='RDEBUG' then o='RDBHELP.hl2'
  56.    else o=fileid.1; end
  57.  if key = '' then call get_key
  58.  pos=pos('(',key)
  59.  char1=left(key,1)
  60.  if left(key,1)="'"  then key=substr(key,2)
  61.  if right(key,1)="'" then key=substr(key,1,length(key)-1)
  62.  lkey=key
  63.  key=translate(key)
  64.  if left(key,1)='X' & length(key)=3 then key=x.rex(key '/G')
  65.  return
  66.  
  67.  GET_KEY:
  68.  c 'LOC :'cursor.3
  69.  here=cursor.3
  70.  /*If cursor.2<1 Then exit msg(me,10,'Cursor not in data area')*/
  71.  key=wordatcursor()
  72.  if  pos(key'(',curline.3)>0 then key = key'('
  73.  if pos(key"'(",curline.3)>0 then key = key"("
  74.  if pos(key'"(',curline.3)>0 then key = key"("
  75.  if  pos("'"key,curline.3)>0 then key = "'"key
  76.  if right(key,1)=':' then key=substr(key,1,length(key)-1)
  77.  key=translate(key,' ','`')
  78.  return
  79.  
  80.  WORDATCURSOR:
  81.  trace o?r  /*T*/
  82.  /*codes="=<>()/,-+&|\][%*;:?'"'"'*/
  83.    codes="=<>()/,-+&|][%*;?'"'"'
  84.  work=' 'translate(curline.3,' ',codes)' '
  85.  If cursor.4=-1 Then Exit MSG(me,10,'Cursor not in file area.')
  86.  If substr(work,cursor.4+1,1)=' '
  87.  Then work=substr(work,1,cursor.4)'`'substr(work,cursor.4+2)
  88.  s=lastpos(' ',work,cursor.4+1)
  89.  if cursor.4+1-s-1>0 then
  90.  Return substr(work,s+1,pos(' ',work,cursor.4+1)-s-1)
  91.  Return 0
  92.  
  93.  COMMAND_REFERENCE_HOST:
  94.  f='e:\doscmd.hlp'
  95.  address command key '/? >' f
  96.  'x' f
  97.  c 'SET msgm OFF'
  98.  '+1'
  99.  if rc = 0 then address command 'del' f
  100.  else do
  101.    'quit'
  102.    msg(me,20,'Keyword:' key 'not found in:' f)
  103.    return 1; end
  104.  return 0
  105.  
  106.  COMMAND_REFERENCE_KEXX:
  107.  f='\kedit\kedit.hlp'
  108.  begin='The KEXX Language'
  109.  return import("if pos('[',curline.3)> 0 | words(curline.3)=1 then rc=1")
  110.  
  111.  COMMAND_REFERENCE_REXX:
  112.  if pc? then do
  113.    f='\rexx\rexx.hlp'
  114.    begin='Instructions'
  115.    case='UPPER RESPECT'
  116.    call import "if pos('[',curline.3)> 0 then rc=1"; end
  117.  return result
  118.  
  119.  COMMAND_REFERENCE_XEDIT:
  120.  if pc? then do
  121.    f='\kedit\kedit.hlp'
  122.    if word(key,1)='SET' then key='[SET]' word(key,2)
  123.    if key='LOCATE' then key= '[LOCATE'
  124.    keys=key
  125.    key='  'key
  126.    begin='* KEDIT Commands:'
  127.    call import "if pos('[',curline.3)> 0 | words(curline.3)=1 then rc=1"
  128.    if result=0 then do
  129.      key='[SET] 'substr(key,3)
  130.      begin='KEDIT SET Options'
  131.      call import "if pos('[',curline.3)> 0 | words(curline.3)=1 then rc=1"
  132.      key=keys
  133.    end
  134.    if result=0 then call language_rexx
  135.  end
  136.  return result
  137.  
  138.  FIND_FILE:
  139.  arg drive
  140.  if pos(':',key)>0 then drive=''
  141.  if get_file(fn'.'ft) then return 1
  142.  'dosquiet' 'dir' drive''key '/s >' h
  143.  'x' h
  144.  c 'SET msgm OFF'
  145.  'loc /Directory/'
  146.  if rc = 0 then do
  147.    'extract /curline'
  148.    parse var curline.3 . . path .
  149.    'loc /-/&/:/'
  150.    if rc = 0 then do
  151.      'extract /curline'
  152.      parse var curline.3 fn ft .
  153.      if right(path,1)<>'\' then path=path'\'
  154.      'quit'
  155.      return get_file(path''fn'.'ft)
  156.    end
  157.  end
  158.  'quit'
  159.  return 0
  160.  
  161.  FINDKEY:
  162.  if words(key)=1 then 'all' '/'key
  163.  else  'all' '/'word(key,1)'/|/'word(key,2)'/'
  164.  return rc
  165.  
  166.  GET_FILE:
  167.  arg ff
  168.  c 'x' ff
  169.  c 'SET msgm OFF'
  170.  newfile?=1
  171.  '+1'
  172.  return (rc=0)
  173.  
  174.  FUNCTION_REFERENCE:
  175.    f='\rexx\rexx.hlp'
  176.    begin='Built-in Functions'
  177.    call import "if pos('(',curline.3)> 0 then rc=1"
  178.  return
  179.  
  180.  IMPORT:
  181.  arg termination
  182.  c 'set autosave off'
  183.  c 'x' f
  184.  c 'SET msgm OFF'
  185.  c 'loc /'begin
  186.  c 'set case' case
  187.  c 'set wrap off'
  188.  c 'loc /'key
  189.  src=rc
  190.  c 'extract /curline/line'
  191.  if src=0 then do
  192.    'x' o
  193.    c 'SET msgm OFF'
  194.    c 'input' '@@'copies('-',70)
  195.    do n=1 to 22
  196.      'x' o
  197.      c 'SET msgm OFF'
  198.      c 'input' '@@' curline.3
  199.      'x' f
  200.      c 'SET msgm OFF'
  201.      '+1'
  202.      if rc<> 0 then leave
  203.      c 'extract /curline'
  204.      interpret termination
  205.      if rc<>0 then leave
  206.    end
  207.    'x' o
  208.    c 'SET msgm OFF'
  209.    c 'input' '@@'copies('-',70)
  210.    'x' f
  211.    c 'SET msgm OFF'
  212.  end
  213.  'loc :'line.1+6
  214.  'quit'
  215.  c 'set autosave' autosave.1
  216.  if src<>0 then do
  217.    c 'EMSG Citation:' key 'not found in' f
  218.    newfile?=1; end
  219.  return src
  220.  
  221.  LANGUAGE_REXX:
  222.  Select
  223.    When char1 = "'"  then Call command_reference_host
  224.    When pos>0        Then Call function_reference
  225.    When key='DO'     Then Call template_rexx_do
  226.    When key='IF'     Then Call template_rexx_if
  227.    When key='SELECT' Then Call template_rexx_select
  228.    When key='PARSE'  Then Call template_rexx_parse
  229.    When key='CALL'   Then Call template_rexx_call
  230.    Otherwise do
  231.      Call command_reference_rexx
  232.      if result<>0 then call findkey; end
  233.  End
  234.  Return
  235.  
  236.  LANGUAGE_XEDIT:
  237.  ':1 extract /curline'
  238.  c 'loc :'here
  239.  Select
  240.    When char1 = "'"  then Call command_reference_xedit
  241.    When pos>0        Then Call function_reference
  242.    When key='DO'     Then Call template_rexx_do
  243.    When key='IF'     Then Call template_rexx_if
  244.    When left(curline.3,1)='*' then call language_kexx
  245.    When key='SELECT' Then Call template_rexx_select
  246.    When key='PARSE'  Then Call template_rexx_parse
  247.    When key='CALL'   Then Call template_rexx_call
  248.    Otherwise do
  249.      call command_reference_xedit
  250.      if result<>0 then do
  251.        Call command_reference_rexx
  252.        if result<>0 then Call findkey; end
  253.    End
  254.  End
  255.  Return
  256.  
  257.  LANGUAGE_KEXX:
  258.  Select
  259.    When key='IF'     Then Call template_rexx_if
  260.    Otherwise do
  261.      Call command_reference_kexx
  262.      if result<> 0 then do
  263.        call command_reference_xedit
  264.        if result<>0 then Call findkey; end
  265.    end
  266.  End
  267.  Return
  268.  
  269.  NOTE_BOOK:
  270.  if pc? then f='c:\let\note.log'
  271.  'x' f
  272.  c 'SET msgm OFF'
  273.  'shad off'
  274.  'all /'key'/'
  275.  newfile?=1
  276.  Return
  277.  
  278.  LOCATE_FILE:
  279.  if validname(key,0) then do
  280.    parse value parsefn(key) with . . fn ft
  281.    if ft='ARC' | ft='ZIP' then do
  282.      push 'ALL /'fn
  283.      return get_file('c:\doc\disklib.hlp'); end
  284.    upper curline.3
  285.    if pos(key'*',curline.3)>0 then ft='*'
  286.    if ft='EXE' | ft='COM'|ft='*' then do
  287.      push 'ALL /'fn
  288.      return get_file('c:\doc\system.hlp'); end
  289.    h='e:hypertxt.fil'
  290.    i=pos('\',key)
  291.    if i>0 then return get_file(key)
  292.    if pos(':',key)>0 then key=substr(key,3)
  293.    if i=0 then key='\'key
  294.    if find_file('c:') then return
  295. /*   if find_file('d:') then return*/
  296.    'EMSG File:' key 'not found.'; end
  297.  else 'EMSG Invalid filename:' key
  298.  return
  299.  
  300.  TEMPLATE_REXX_CALL:
  301.  c 'msg Enter Subroutine name...'
  302.  if pc? then do
  303.    c 'readv cmdline'
  304.    label=readv.1; end
  305.  c 'input Call' label
  306.  c 'add'
  307.  c 'input' translate(label)':'
  308.  c 'add'
  309.  c 'add'
  310.  c 'add'
  311.  c 'input Return'
  312.  Return
  313.  
  314.  TEMPLATE_REXX_DO:
  315.  c 'input' 'Do name=expri To exprt By exprb For exprf While/Until exprw'
  316.  c 'input' 'Do expr/Forever While/Until exprw'
  317.  c 'add'
  318.  c 'input End'
  319.  Return
  320.  
  321.  TEMPLATE_REXX_IF:
  322.  c 'input If expression Then Do'
  323.  c 'add'
  324.  c 'input End'
  325.  c 'input Else Do'
  326.  c 'add'
  327.  c 'input End'
  328.  Return
  329.  
  330.  TEMPLATE_REXX_PARSE:
  331.  c 'input Parse Upper Arg'
  332.  c 'input Parse Upper Linein template'
  333.  c 'input Parse Upper Pull template'
  334.  c 'input Parse Upper Source template'
  335.  c 'input Parse Upper Value [expression] With template'
  336.  c 'input Parse Upper Var name'
  337.  c 'input Parse Upper Version'
  338.  Return
  339.  
  340.  TEMPLATE_REXX_SELECT:
  341.  c 'input Select'
  342.  do 3
  343.    c 'input   When expression Then Do'
  344.    c 'input   End'
  345.  end
  346.  c 'input   Otherwise Do'
  347.  c 'input   End'
  348.  c 'input End'
  349.  Return
  350.