home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-386-Vol-2of3.iso / v / vsnbl220.zip / CROSS.SNO < prev    next >
Text File  |  1991-02-14  |  2KB  |  57 lines

  1. * CROSS.SNO - Print all intersections between two words
  2. *
  3. *    Sample program from Chapter 6 of the Tutorial
  4. *
  5.     &TRIM    = 1
  6.  
  7. *  Get words from user
  8. *
  9. AGAIN    OUTPUT    = 'ENTER HORIZONTAL WORD:'
  10.     H    = INPUT                    :F(END)
  11.  
  12.     OUTPUT    = 'ENTER VERTICAL WORD:'
  13.     V    = INPUT                    :F(END)
  14.  
  15. *  Make copy of horizontal word to track position.
  16.     HC    = H
  17.  
  18. *  Find next intersection in horizontal word.  Save
  19. *  the number of preceding horizontal characters in NH.
  20. *  Save the intersecting character in CROSS.
  21. *  Replace with '*' to remove from further consideration.
  22. *  Go to AGAIN to get new words if horizontal exhausted.
  23. *
  24. NEXTH    HC @NH ANY(V) . CROSS = '*'            :F(AGAIN)
  25.  
  26. *  For each horizontal hit, iterate over possible
  27. *  vertical ones.  Make copy of vertical word to track
  28. *  vertical position.
  29. *
  30.     VC    = V
  31.  
  32. *  Find where the intersection was in the vertical word.
  33. *  Save the number of preceding vertical characters in NV.
  34. *  Replace with '#' to prevent finding it again in that
  35. *  position.  When vertical exhausted, try horizontal again.
  36. *
  37. NEXTV    VC @NV CROSS = '#'                :F(NEXTH)
  38.  
  39. *  Now display this particular intersection.
  40. *  We make a copy of the original vertical word,
  41. *  and mark the intersecting position with '#'.
  42. *
  43.     OUTPUT    =
  44.     PRINTV    = V
  45.     PRINTV POS(NV) LEN(1) = '#'
  46.  
  47. *  Peel off the vertical characters one-by-one.  Each will
  48. *  be displayed with NH leading blanks to get it in the
  49. *  correct column.  When the '#' is found, display the full
  50. *  horizontal word instead.
  51. *  When done, go to NEXTV to try another vertical position.
  52. *
  53. PRINT    PRINTV LEN(1) . C =                :F(NEXTV)
  54.     OUTPUT = DIFFER(C,'#') DUPL(' ',NH) C        :S(PRINT)
  55.     OUTPUT = H                    :(PRINT)
  56. END
  57.