If you decide you want your variable to hold a number you simply have to set it like this.
- SOMEVAR = 132
If you decide you want it to be a string, you must end the variable name with $.
- SOMEVAR$ = "Hey there!"
There are plenty of things you can do with a variable, below are just a few examples.
- ANUMBER = 132
- ASTRING$ = "This is text"
- PRINT ANUMBER 'This will simply print: 132
- PRINT ASTRING$ 'This will simply print: "This is text"
- '-----------
- ASTRING$ = "Your number: " 'You can redefine a variable at any time
- ANUMBER = ANUMBER + 5 'You can also do math!
- PRINT ASTRING$;ANUMBER 'You can also print multiple variables at once, separate with ;
- 'The above will print: Your number: 137
- '----------
- STRINGA$ = "Hello "
- STRINGB$ = "there,"
- ASTRING$ = STRINGA$;STRINGB$ 'You can also join two strings together
- PRINT ASTRING$;" and thats all!" 'You can still manually add to your print command as well.
- 'The above will print: Hello there, and that is all!
I hope you understand this basic introduction into variables. If you have any questions feel free to comment and ask.
No comments:
Post a Comment