home *** CD-ROM | disk | FTP | other *** search
/ AMOS PD CD / amospdcd.iso / totallyamos / issue4 / programming / 7.seq < prev    next >
Encoding:
Text File  |  1992-05-01  |  6.5 KB  |  148 lines

  1. ddd00000ff00fe0080000a7f
  2. ^1VvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvV
  3.  
  4. ^2               A M O S   F O R   B E G I N N E R S . 
  5.  
  6. ^2F R O M  T H E  A G E   O F   F I V E   T O   N I N E T Y - F I V E .
  7.  
  8. ^1VvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvV
  9.  
  10. ^6 We  have decided to rename the Amos for Kids section from this issue
  11. ^6onwards.  This is because:-
  12.  
  13. ^7a)  It  seems  that not many people actually read Amos For Kids as it
  14. ^7was for kids not adults.
  15.  
  16. ^7b)  There were suggestions in the questionnaire that there was a need
  17. ^7for  a section to be dedicated to those with little or no programming
  18. ^7knowledge.
  19.  
  20. ^6 Therefore  we  have  decided to combine the two.  You want tutorials
  21. ^6which  explain the basics of Basic, well, you've had that in Amos for
  22. ^6Kids  since  Issue 1 without knowing it!  So dig out your back issues
  23. ^6of  TA  and  forget the title and read Amos for Kids.  Perhaps you'll
  24. ^6find something useful!
  25.  
  26. ^5 It would be pretty wasteful to have 2 sections that contain the same
  27. ^5articles but have different titles, wouldn't it?
  28.  
  29. ^1VvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvV
  30.  
  31. ^2 Instead  of  the  usual  tutorial  this  issue,  we shall attempt to
  32. ^2explain some Basic/Amos commands in more user friendly English!  This
  33. ^2is a suggestion which came in with the survey forms.
  34.  
  35. ^1 We  shall  assume  that  the  readers of this article know little or
  36. ^1nothing  about  Basic, so we'll try to explain things from that point
  37. ^1of  view.  So as not to offend anyone, if you have already learnt the
  38. ^1things explained here, skip through the article, if not read on.
  39.  
  40. ^2 Let's take a look at VARIABLES and ARRAYS.
  41.  
  42. ^1 The  information  you give to a computer is called DATA, if you want
  43. ^1your computer to store this data in its memory, you will have to give
  44. ^1it  a  label.   The  label is called a VARIABLE and when you want the
  45. ^1computer to do something with the stored Data, you refer to it by its
  46. ^1variable  name.  It is called a Variable because the data to which it
  47. ^1refers can change during the program.
  48.  
  49. ^6 Numeric  variables  can  only remember numbers, if you want to store
  50. ^6letters  or  words  as  well,  then  you  will  need  to use a string
  51. ^6variable.
  52.  
  53. ^1 You  can  use  a word or a letter as a variable name, but be careful
  54. ^1not  to use a word that starts with a Basic command name as this will
  55. ^1confuse  the  computer!  A string variable name must be followed by a
  56. ^1`$' eg A$ or PEACH$.
  57.  
  58. ^6 Variable  names  such as DATA$, RUN$, EDITOR$ or PROCEDURE$ would be
  59. ^6illegal  as  they  are  Amos  commands.   If you used `_'as the first
  60. ^6character, it would be allowable eg _DATA$.
  61.  
  62. ^2 ARRAYS
  63.  
  64. ^1 An  array  is  a  set of data items held together under one variable
  65. ^1name.  You can imagine the variable as space in the computer's memory
  66. ^1with lots of compartments.  Arrays can be one-dimensional, that is, a
  67. ^1single  line  of  boxes,  or two-dimensional and have several rows of
  68. ^1boxes.  You refer to an item in a one-dimensioned array by the number
  69. ^1of the box it is in eg in the diagram below, A$(4) is PLUM.
  70.  
  71. ^4                                 A$
  72. ^6              ______   ________   _____    ____   _____
  73. ^6             |   ^21  ^6| ^6|   ^22    ^6| ^6|  ^23  ^6|  ^6| ^24  ^6| ^6|  ^25  ^6|
  74. ^6             |^4APPLE ^6| ^6| ^4BANANA ^6| ^6|^4PEACH^6|  ^6|^4PLUM^6| ^6|^4PEAR ^6|  
  75. ^6             |      | |        | |     |  |    | |     |
  76. ^6              ------   --------   -----    ----   -----
  77.  
  78. ^1For two-dimensioned arrays you have to give the number of the row and
  79. ^1the column eg D(3,2) is 15.
  80.  
  81. ^4                                  D
  82. ^1                         1        2        3
  83. ^6                     __________________________
  84. ^6                    |        |        |        |
  85. ^4                  1 ^6|   ^25    ^6|   ^212   ^6|   ^216   ^6|
  86. ^6                    |________|________|________|
  87. ^6                    |        |        |        |
  88. ^4                  2 ^6|   ^23    ^6|    ^22   ^6|    ^27   ^6|
  89. ^6                    |________|________|________|
  90. ^6                    |        |        |        |
  91. ^4                  3 ^6|   ^28    ^6|   ^215   ^6|   ^211   ^6|
  92. ^6                    |________|________|________|
  93. ^6                    |        |        |        |
  94. ^4                  4 ^6|   ^24    ^6|    ^21   ^6|    ^27   ^6|
  95. ^6                    |________|________|________|
  96.  
  97. ^1 Before  you  use an array you will have to tell the computer how big
  98. ^1it  will  be  using the word DIM (short for dimension).  In the above
  99. ^1example, you would use DIM D(4,3) (4 rows, 3 columns).  For the first
  100. ^1example, you would use DIMA$(5).  (It has 5 elements).
  101.  
  102. ^4 The  DIM  statement  should be at the beginning of the program as it
  103. ^4must only be used once.
  104.  
  105. ^1 Arrays  are a useful way of storing data.  An array is a set of data
  106. ^1items  held  together under one variable name.  Each item in an array
  107. ^1is  called  an element and the number of its position in the array is
  108. ^1called its subscript.
  109.  
  110. ^7 Numeric Arrays
  111. ^4                            Variable name-  N
  112. ^7                             These numbers are the subscripts
  113. ^7                                            |
  114. ^2                         1       2       3       4       5       6
  115. ^4These are the elements- ^61066     1216    1485    1603    1665    1959
  116.  
  117. ^1 Here is a numeric array called N.  It contains 6 elements.  You need
  118. ^1to  tell  the  computer  how  big an array will be so that it can put
  119. ^1aside  enough  space  in its memory.  To do this you use the word DIM
  120. ^1followed  by  the  array name and the number of elements it contains.
  121. ^1This is called dimensioning an array.
  122.  
  123. ^4  DIM N(6)
  124.  
  125. ^1 Numeric variables can only remember and store numbers.
  126.  
  127. ^4 String Arrays
  128. ^2                1        2        3       4        5
  129. ^4               LEN     ANNE    MELANIE   BEN     PIPPA
  130.  
  131. ^1 This  is  a  string  array, we'll call it TUCKER$ as it contains the
  132. ^1names  of  our family and it would then be easy to remember if it was
  133. ^1needed  in  a  program! 
  134. ^1 It contains 5 elements, so you would use DIM TUCKER$(5).
  135.  
  136. ^4  They  are  handled  in  the  same  way  as  numeric arrays, but can
  137. ^4remember and store words or letters as well as numbers.
  138.  
  139. ^2 This  has  been  written  by  a  non programmer with the aid of `The
  140. ^2Beginner's programming Handbook' by Usbourne Books. It's an old book,
  141. ^2and deals with Basic in general. The theory is  if  I  can understand
  142. ^2what I'm writing, then anyone reading this might stand a chance!
  143. ^3                                Anne.
  144.  
  145. ^1VvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvV
  146.  \
  147.  
  148.