home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 10: Diskmags / nf_archive_10.iso / MAGS / ST_PLUS / STP18.MSA / STP_VAR_DIM.STP < prev    next >
Text File  |  1997-06-30  |  4KB  |  114 lines

  1. <PICLOAD>CORNER.DAJ
  2.    
  3.  
  4. <PICSHOWD>048,085,272,113,048 
  5.  
  6.  
  7.  
  8.  
  9.  
  10.                                    BY DEANO 
  11.  
  12. Varibles  and  Dimensions are a way of storing information in STOS  to  use  in  
  13. your program,  the two main pieces of info are words and numbers. Your  program 
  14. would make a desision if one of these equaled something and act apon  it. Heres 
  15. a simple example of a varible being used.
  16.  
  17.   VARIBLES:
  18.  
  19. 10 print "Please type in a number" 
  20. 20 input A 
  21. 30 print "You choose the number";A 
  22.  
  23. What  happens  here  is that the computer labels a little box  called  'A'  and  
  24. inserts  the number you typed in at the input prompt into it.  The  number  you  
  25. typed  is now stored in the computers memory in a little box called  'A'.  Line  
  26. 30 looks in the box and prints its contents to the screen,  which of course  is 
  27. the number you entered.
  28.  
  29. 'A'  is  the name we have chosen for the varible and the input command  is  one  
  30. way  of  putting information into it.  Another way to put  information  into  a  
  31. varible is like this.
  32.  
  33. 10 let NUMBER=100 
  34. 20 print NUMBER 
  35.  
  36. Line  10  tells the computer to get one of its boxes and stick a  label  on  it  
  37. calling it NUMBER,  then put the value '100' inside it.  Note,  the use of  the  
  38. command 'let' is optional and can be removed so your routine would be.
  39.  
  40. 10 NUMBER=100 
  41. 20 print NUMBER 
  42.  
  43. Varibles can be called anything you wish,  either a letter or a word,  but  you  
  44. must  make  sure that there are no STOS commands in the name or  else  you  get  
  45. something like this......
  46.  
  47. 10 sin GLE=10 
  48.  
  49. If  you  used  the word 'SINGLE' then STOS finds the  command  'sin'  and  gets  
  50. confused. Try different names until you find one that appears in capitals.
  51.  
  52. Not  only  numbers can be used in varibles,  so can words or  letters.  If  you  
  53. wanted  to put a word into a varible then you must add a '$' to  the  varible's  
  54. name, and the word must be put inbetween two quotes. For example.
  55.  
  56. 10 NAME$="DEANO" 
  57. 20 print "MY NAME IS ";NAME$ 
  58.  
  59. 10 input "What is your name";NAME$ 
  60. 20 print "Hello There ";NAME$ 
  61.  
  62. You  can  also add varible values together which can be used in a game  to  add  
  63. points to your score, for example.
  64.  
  65. 10 SC=100 
  66. 20 print "Your score is ";SC 
  67. 30 print "Press a Key" 
  68. 40 SC=SC+10 : goto 20 
  69.  
  70. Line  40 tells the varible SC to equal the value of itself which is  '100'  and  
  71. the add '10' to itself.  The same applies to letters, usually known as  strings 
  72. of characters. For example.
  73.  
  74. 10 input "What is your first name";NAME$ 
  75. 20 input "What is your second name";SURNAME$ 
  76. 30 A$=NAME$+" "+SURNAMES 
  77. 40 print "Hello ";A$ 
  78.  
  79.   DIMENSIONS:
  80.  
  81. As  you  know,  a  varible  is a little box  inside  the  computers  memory.  A  
  82. dimension  is a large box full of little boxes.  Think of a cassette  box,  its  
  83. one  big box with so many slots for your cassettes.  A dimension allows you  to  
  84. store  so many pieces of information inside one varible.  Heres an  example  of  
  85. how one could be used.
  86.  
  87. 10 dim A(2) : rem Set up one varible box with two slots 
  88. 20 A(1)=100 : A(2)=200 
  89. 30 print A(1),A(2) 
  90.  
  91. The same method can be used with strings.
  92.  
  93. 10 dim NAME$(2) 
  94. 20 NAME$(1)="ST" : NAME$(2)="PLUS" 
  95. 30 print NAME$(1),NAME$(2) 
  96.  
  97. Dimensions  can be used exactly the same way as varibles,  the only  difference  
  98. is  that with dimensions you use the varible name plus the number of  slots  in  
  99. the varible box....IE: dim SC(10).
  100.  
  101. Another type of dimension is the two way dimension. This is setting up so  many 
  102. boxes with so many slots. Try this example.
  103.  
  104. 10 dim NUMBER(5,10) : rem Set up five boxes each with ten slots.
  105. 20 NUMBER(1,1)=100 : rem Put '100' in box one, slot one 
  106. 30 NUMBER(2,1)=500 : rem Put '500' in box two, slot one.
  107. 40 print NUMBER(1,1) 
  108. 50 print NUMBER(2,1) 
  109.  
  110. Errm, and thats it.....see you all next month.
  111.  
  112. DEANO 
  113.  
  114.