home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / o / ops5.zip / TEST2.OPS < prev    next >
Text File  |  1992-05-31  |  1KB  |  75 lines

  1.  
  2. (literalize loop                 ;  loop counter
  3.     count)
  4. (literalize buf                  ;  input buffer
  5.     input)
  6. (literalize buffield             ;  holds an atom from the input
  7.     extracted value)
  8.  
  9. (vector-attribute input)
  10.  
  11. (literal extracted = 2
  12.          value     = 3)
  13.  
  14. ; Test acceptline
  15.  
  16. (p p1
  17.      (start)              ;  begin here
  18.     -->
  19.      (make loop ^count 1)
  20.      (make buffield ^extracted FALSE ^value nil) )
  21.  
  22.  
  23. (p p2
  24.      (loop ^count 1)        ;  Get a new line of input
  25.     -->
  26.      (write (crlf) Enter a line of "input: ")
  27.      (make buf ^input (acceptline nothing read))
  28.      (modify 1 ^count 2) )
  29.  
  30.  
  31.  
  32.  
  33. (p p3
  34.      (loop ^count { <x> > 1 < 128 })    ;  Extract a field
  35.      (buf ^input <> end-of-file)
  36.      (buffield ^extracted FALSE)
  37.     -->
  38.       (modify 3 ^extracted TRUE ^value (substr 2 <x>  <x>)) )
  39.  
  40.  
  41.  
  42. (p p4
  43.     (loop ^count <x>)         ;  Print non-nil field
  44.     (buffield ^extracted TRUE ^value { <v> <> nil })
  45.        -->
  46.         (write (crlf) Field <x> is <v>)
  47.         (modify 1 ^count (compute (<x> + 1)))
  48.     (modify 2 ^extracted FALSE) )
  49.  
  50.  
  51.  
  52. (p p5
  53.     (loop ^count <x>)         ;  Skip over nil field
  54.     (buffield ^extracted TRUE ^value nil)
  55.        -->
  56.         (modify 1 ^count (compute (<x> + 1)))
  57.     (modify 2 ^extracted FALSE) )
  58.  
  59.  
  60.  
  61. (p p6
  62.     (loop ^count 128)         ;  Start over again
  63.     (buf)
  64.        -->
  65.     (modify 1 ^count 1)
  66.     (remove 2) )
  67.  
  68.  
  69.  
  70. (p p7
  71.     (buf ^input end-of-file)     ;  Exit on EOF
  72.        -->
  73.     (write (crlf) End-of-file reached in input.)
  74.     (halt) )
  75.