home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / fpc / source / hyper.seq < prev    next >
Encoding:
Text File  |  1989-09-21  |  2.0 KB  |  40 lines

  1. \ HYPER.SEQ     Simple ALL Vocabulary search for FPC     by Tom Zimmer
  2.  
  3. \ a couple of definition search words. The first HFIND searches all possible
  4. \ vocabularies, the second VFIND searches a specific vocabulary for a word.
  5.  
  6. \ HYPERTEXT find word searches all vocabularies. First vocs in search order
  7. \ then FORTH, then all vocs in VOC-LINK in reverse defined order until found.
  8. : hfind         ( a1 -- a2 f1 )         \ a1 = counted word
  9.                                         \ a2 = the CFA if a1 found
  10.                                         \ a2 = a1 if a1 was not found
  11.                                         \ f1 boolean TRUE if found
  12.                 ?uppercase find ?dup ?exit              \ leave if found
  13.                 dup>r ['] forth >body                   \ check FORTH first
  14.                 over.swap.hash.@ (find) ?dup 0=
  15.                 if      voc-link @                      \ then the rest
  16.                         begin   r@ over #threads 2* -
  17.                                 over.swap.hash.@ (find)
  18.                                 if      nip nip
  19.                                         true true
  20.                                 else    drop
  21.                                         @ dup 0=
  22.                                 then
  23.                         until
  24.                 then    r>drop ;
  25.  
  26. \ Search a specific vocabulary for the word specified.
  27. \ The counted string a1 is moved to here, 2 blanks are appended, and it
  28. \ is conditionally converted to uppercase. Vocabulary CFA a2 is then
  29. \ searched for the word
  30. : vfind         ( a1 a2 --- a3 f1 )     \ a1 = counted word
  31.                                         \ a2 = vocabulary CFA
  32.                                         \ a3 = the CFA if a1 found
  33.                                         \ a3 = a1 if a1 was not found
  34.                                         \ f1 boolean TRUE if found
  35.                 swap here over c@ 1+ cmove
  36.                 $2020 here count + !
  37.                 ?uppercase swap >body
  38.                 over.swap.hash.@ (find) ;
  39.  
  40.