home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 164.lha / ARexx / TXed_ARexx / lookitup.txed < prev    next >
Text File  |  1988-04-28  |  1KB  |  47 lines

  1. /* Look up routine for ref */
  2. 'LOCK 1'  /* Prevent user input (he may get bored) */
  3. /* We get word to look up from ref.txed. Ref opened refport for synchonization.
  4.    After we open our port (lookport), we'll tell ref to send us the word. */
  5.  
  6. call openport("lookport")
  7. address 'refport' 'Ready'
  8. call waitpkt('lookport')
  9. packet = getpkt('lookport')
  10. lookup = getarg(packet)
  11. call reply(packet,0)
  12. call closeport("lookport")
  13.  
  14. 'MSG' lookup
  15.  
  16. found = 'false'
  17. call open(ref,'s:txed.ref','R') /* our ref file */
  18. do while ((found = 'false') & (~eof(ref)))
  19.    fileline = readln(ref)
  20.    if (upper(word(fileline,1)) = upper(lookup)) then found = 'true' /* found reference */
  21.    end
  22. call close(ref)
  23. if found = 'false' then do
  24.    'MSG' 'reference not found!'
  25.    exit
  26.    end
  27.  
  28. /* God, I love the parse command! */
  29. parse var fileline dummy filename '@' start '@' end '@'
  30. filename = strip(filename) /* remove blanks */
  31.  
  32. /* Solution to the speed problem was obvious! Let txed cull the file
  33.    rather than trying to do it in AREXX. Txed can jump and cut easily,
  34.    whereas AREXX had to read lines one at a time.                      */
  35. 'LOA' filename
  36. 'T'
  37. 'MAR 1'
  38. 'JU' start-1
  39. 'CUT'
  40. 'JU' end - start + 2
  41. 'MAR 1'
  42. 'B'
  43. 'CUT'
  44.  
  45.  
  46. /* Window <- Sample ref word */
  47.