home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / tipi / varsampl.tpi < prev   
Text File  |  1993-11-07  |  2KB  |  74 lines

  1. # VARSAMPLE.TPI
  2. # by Kent Peterson
  3. # This program demonstrates the three
  4. # types of variables in TIPI along with
  5. # the table data structure.
  6.  
  7. defvar price
  8. 3 defarray zipcode
  9.  
  10. defstr Man$
  11.  
  12.  
  13. deftable kid$           # This sets the
  14.  "Bart" "Lisa" "Maggie" # table kid$ to
  15. endtable                # to hold the names
  16.                         # of three kids.
  17.  
  18. 100 price store         # This stores 100 in
  19.                         # the variable price.
  20.  
  21. 10605 1 zipcode store   # This stores
  22. 60609 2 zipcode store   # different zipcodes
  23. 90210 3 zipcode store   # in each of the
  24.                         # three zipcode
  25.                         # slots.
  26.  
  27. "Homer" Man$ store      # This stores the
  28.                         # word "Homer" in
  29.                         # the variable Man$.
  30.  
  31. # Now let's use these variables
  32. # and the table
  33.  
  34. "Hi, I'm " print$
  35. Man$ fetch print$       # You have to fetch
  36.                         # the contents of
  37.                         # a variable before
  38.                         # you can print it out.
  39. "." print$ cr
  40.  
  41. "My kids are named "
  42. print$
  43. 1 kid$ print$           # Tables are initialized
  44.                         # when they are defined
  45.                         # and they auto-fetch.
  46.                         # DO NOT USE A FETCH
  47.                         # with a table.
  48. ", " print$
  49. 2 kid$ print$
  50. " and " print$
  51. 3 kid$ print$
  52. "." print$ cr cr
  53.  
  54. "My car cost $" print$
  55. price fetch print
  56. "." print$ cr cr
  57.  
  58. "My zipcode is " print$
  59. 1 zipcode fetch print   # Array values
  60.                         # are fetched and
  61.                         # and stored using
  62.                         # their names and
  63.                         # their index values.
  64. " but I wish it was "
  65. print$
  66. 3 zipcode fetch print
  67. "." print$ cr
  68.  
  69.  
  70. begin key until     # This sequence of
  71.                     # instructions waits
  72.                     # until you press
  73.                     # a key.
  74.