lang_ref_variables.html 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type"
  4. content="text/html; charset=iso-8859-1">
  5. <title>Language Reference - Variables</title>
  6. <link rel="stylesheet" href="lang_ref.css" type="text/css">
  7. </head>
  8. <body><br>
  9. &nbsp;<span class="Command">&nbsp;Variables&nbsp;</span><br>
  10. <blockquote>
  11. <p>Variables may be of any basic data type, or a custom type. A variable's type
  12. is determined by a special character that follows its identifier.<br>
  13. <br>
  14. <span class="header"> Variable Types</span></p>
  15. <blockquote>
  16. <p>These special characters are called 'type tags' and are: </p>
  17. </blockquote>
  18. </blockquote>
  19. <table width="90%" border="0" cellspacing="0" cellpadding="0" align="center">
  20. <tr>
  21. <td>
  22. <blockquote><br>
  23. <p> % = For integer variables </p>
  24. <p> # = For floating point variables </p>
  25. <p> $ = For string variables </p>
  26. <p> .{typename} For custom type variables</p>
  27. </blockquote>
  28. </td>
  29. </tr>
  30. </table>
  31. <blockquote>
  32. <blockquote>
  33. <p> Here are some examples of valid variables: </p>
  34. </blockquote>
  35. </blockquote
  36. >
  37. <table width="90%" border="0" cellspacing="0" cellpadding="0" align="center">
  38. <tr>
  39. <td height="268">
  40. <p><br>
  41. </p>
  42. <blockquote>
  43. <p>Score%</p>
  44. <p>Lives% </p>
  45. <p>x_speed# </p>
  46. <p>y_speed# </p>
  47. <p>name$ </p>
  48. <p>title$ </p>
  49. <p>ali.Alien </p>
  50. <p>player.Player</p>
  51. </blockquote>
  52. </td>
  53. </tr>
  54. </table>
  55. <blockquote>
  56. <blockquote>
  57. <p>The type tag only needs to be added the first time you use a variable,
  58. after that you can leave the type tag off if you wish. <br>
  59. <br>
  60. If you don't supply a type tag the first time a variable is used, the variable
  61. defaults to an integer. <br>
  62. </p>
  63. <p>It is illegal to use the same variable name with a different type. For
  64. example, if you already have an integer variable called 'name%', it is illegal
  65. to also have a string variable called 'name$' <br>
  66. </p>
  67. </blockquote>
  68. <p class="header">Setting Variables</p>
  69. <blockquote>
  70. <p>The '=' keyword is used to assign a value to a variable. For example: </p>
  71. <blockquote>
  72. <p><i>score%=0 </i></p>
  73. </blockquote>
  74. <p> ... assigns the value '0' to the integer variable 'score'.</p>
  75. </blockquote>
  76. <p><span class="header">Variable Scope</span><br>
  77. </p>
  78. <blockquote>
  79. <p>Variables may also be either '<b>global</b>', or '<b>local</b>'. This refers
  80. to where in a program a variable may be used.</p>
  81. <blockquote>
  82. <p>- <b>Global variables</b> can be used from anywhere in the program. <br>
  83. <br>
  84. - <b>Local variables</b> can only be used within the function they are
  85. created in. </p>
  86. </blockquote>
  87. <p> The '<b>Global</b>' keyword is used to define one or more global variables.
  88. For example: </p>
  89. <blockquote>
  90. <p><i>Global Score=0,Lives=3,Player_up=1 </i></p>
  91. </blockquote>
  92. <p> ... defines 3 global variables. </p>
  93. <p> Similarly, '<b>Local</b>' is used to define local variables: </p>
  94. <blockquote>
  95. <p><i>Local temp_x=x,temp_y=y </i></p>
  96. </blockquote>
  97. <p>If you use a variable without defining it as either local or global, it
  98. defaults to being local. </p>
  99. </blockquote>
  100. </blockquote>
  101. </body>
  102. </html>