;------------------------------------------------------------------------------- ; ; ;-------------------------------; ; ; Single Basic Variables ; ; ;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,; ; ; This part can be run in one go. ; No need for copying or pasting. ; ;------------------------------------------------------------------------------- ; ; Imagine a variable in which ; you want to store a number. ; Variable = 5 ; ; However, this is not just a variable. ; It is actually an Integer variable. ; You can store natural numbers in it. ; All variables are by default integer. ; Who = -1 What = 12345 Where = 0 Why = 100 How = 54321 ; ; All these are integer variables. ; You cannot store text in them, ; nor cats, lemmings, goblins ; or floating point numbers. ; ; Variables are created automatically ; when they are used for the first time. ; You can specify of which type they have to be, ; so you can store whatever you'd like to store. ; ; [Variable name][Variable type] ; ; Below are the available (basic) variable types: ; ; % Integer variable ; # Floating point variable ; $ String variable ; .[Type name] Pointer variable (more about this later) ; ; So when you write ; Variable = 5 ; ; it is exactly the same as ; Variable% = 5 ; ; because all variables are by default Integer. ; ; A floating point variable can hold ; numbers with additional precision, ; as the name suggests. ; ; String variables can be used ; to store text. ; Circle# = 3.14159 ; Float Loaded% = 1 ; Integer Name$ = "TC" ; String ; ; A variable its type cannot be changed ; after it is first called upon. ; This is also why you do not have to include ; the variable type identifier every time. (the what?) ; The %, # or $ thingy behind the variable name. ; ; Example: ; New_Variable$ = "Something New" New_Variable = "Something Else" ; ; There is another way though. ; You can declare a variable for the first time ; without assigning a value to it. ; Local Empty_Variable% ; ; This is a newly created integer variable. ; By default all newly created variables ; will be set to 0 (or empty). ; ; Now you can use the same variable ; excluding the variable type identifier. (eh?) ; The % thingy behind the variable name :) ; Empty_Variable = -12345 ; ; See? ; The % thingy is missing. ; ; You may be wondering about what Local means. ; Each variable has a certain range in a program. ; The Local range means that the variable ; can be accessed only in the current routine. ; ; When a variable is used for the first time ; ThisValue = SomethingElse ; ; it is always declared as a Local variable. ; ; There is another range called Global. ; Global variables can be accessed from anywhere. ; Local ShortRange Global LongRange ; ; Here you see two integer variables; ; one is only visible to the current routine, ; and another visible from anywhere. ; But, more on routines later. ; ; You can also combine a declaration ; with an assignment. ; Global PhoneCalls_SinceYesterday# = 11.5 ; ; Creating a new global floating point variable ; and stuffing a value in it right away. ; ; Although, once a variable is declared, ; it cannot be redeclared. ; So once you've declared a variable, ; you cannot change its type (integer, float, etc) ; nor its range (local or global). ; ; There are also so called Constants. ; You put something in them, ; but you cannot change it afterwards. ; So not exactly variables, ; but you can use them as such. ; ; In fact, they behave exactly like Global variables. ; So you can use them anywhere in your program. ; Const Square# = 1.41421 ; Float Const Empty% = -1 ; Integer Const Nick$ = "Ty" ; String ; ; You can even put maths inside a constant, ; so long as the values are constant as well. ; Const Zero = 0 Const One = Zero + 1 ; ; Integer variables can hold numbers in ; the range of -2,147,483,648 and 2,147,483,647. ; Integer_Variable% = 2147483647 ; ; If you were to add 1, ; the contents will flip to the other side. ; Integer_Variable = Integer_Variable + 1 Print "Int: " + Integer_Variable ; ; Floating point variables can hold pretty much anything, ; but the more numbers you want to store, ; the less accurate it will get. ; FloatingPoint_Variable# = 1.11111 ; FloatingPoint_Variable = FloatingPoint_Variable + 0.000006 Print "Float: " + FloatingPoint_Variable ; ; String variables are completely dynamic. ; They can be virtually any size. ; String_Variable$ = "Word" ; ; Simply use some glue to add something. ; String_Variable = String_Variable + "s were wondering where wonders went." Print "String: " + String_Variable ; ; For example you could squeeze an entire dictionary ; into a single string variable :P ; Not very useful though :) ; WaitKey ; Adding some user-friendliness, End ; so you can see the output before the program ends. ; ;-------------------------------------------------------------------------------