green text is being edited and should not be considered
relevant to the tutorial. for a while, it will make up
the bulk of this section.
black text has been edited to be more accurate with
regards to puppybasic.
........................................................................
variables
1 of 9
an intro to puppybasic
chapter 3: variables
........................................................................
........................................................................
variables
2 of 9
variables are the easiest way to store data in memory; of course, this
memory is cleared when the program ends or the machine is turned off,
but variables are useful when you want data in one part of your program
to be available to another line in the program.
there are two main types of variables: string and numeric.
string variable names start with a letter and are made of letters and
numbers.
........................................................................
........................................................................
variables
3 of 9
here is an example of a string variable at work:
q$="hello, world!" ____________________________________________________
PRINT q$ _hello, world!______________________________________
PRINT q$ _hello, world!______________________________________
PRINT q$ _hello, world!______________________________________
PRINT q$ _hello, world!______________________________________
____________________________________________________
this prints the contents of the string variable q$ 4 times.
........................................................................
........................................................................
variables
4 of 9
strings, like those used by the PRINT statement, start and end with a
double quote "like this." you cannot enter a string containing a double
quote:
"like "this example" does,"
later on you'll learn a way around this using the CHR$ function.
string variables almost always end in a dollar sign, while on the other
hand, numeric variables often end without in any special symbol, even
though there are other suffixes for specific types (which you usually
wont need... but you may want them.)
........................................................................
........................................................................
variables
5 of 9
all variables may be named with one or more letters, must start with a
letter, and may include numbers (q2$ or q2 for example) after that.
also, do not give a variable the same name as a statement or function
(like "CLS") if you want your program to work.
it's worth showing that you can print a mix of strings and numbers, like
in the example on the next page...
........................................................................
........................................................................
variables
6 of 9
______________________________________________
n=50 __7 hello, world! 50 times.___________________
PRINT 7; q$; n; "times." ______________________________________________
...and you can combine two strings into one with the + sign like this:
q$="hello"
q$="oh, "+q$+" there..."
now the string "oh, hello there..." is stored in the variable q$.
combining strings this way, with or without variables, is called
"concatonization" and does not work with numeric variables.
........................................................................
........................................................................
variables
7 of 9
there are a couple more things you might want to know before moving on:
it is often preferable (in the interest of time and effort) to type a
question mark: ? "hello."
instead of typing out PRINT, puppybasic will (along with many other
interpreters and compilers) change it to PRINT for you. it won't stop
you from using a question mark where you actually want one:
? "do you want to quit?"
will change to:
PRINT "do you want to quit?"
........................................................................
........................................................................
variables
8 of 9
also, instead of giving each statement its own line, you may often find
you prefer to combine lines of code using a colon :
CLS: PRINT "to whom it may concern"; : PRINT ":"
will clear the screen and PRINT the following:
________________________________________________________________________
_to whom it may concern:________________________________________________
________________________________________________________________________
________________________________________________________________________
........................................................................
........................................................................
variables
9 of 9
COLOR 10: PRINT "dear abby"; : PRINT ","
will print: ___________________________________________________________
_dear abby,________________________________________________
___________________________________________________________
congratulations! if you have not already, you can now write your first
puppybasic program. you will be able to do much more after reading the
next section.
-= end of chapter 3 =-
........................................................................
an intro to puppybasic (chapter 3)
this content is public domain.
........................................................................
click here to go back to the contents page
Before You Post, Please Note...
-> Please Note: By Posting, you agree to submit the contents of your post to the Public Domain <- SEE: howto post to this blog
Friday, February 2, 2007
puppybasic intro ch. 03 - variables
Subscribe to:
Post Comments (Atom)
19 comments:
buy tramadol online buy tramadol online without prescriptions usa - tramadol dosage large dogs
buy tramadol online where can you buy tramadol online - tramadol 50 mg kapsler
buy tramadol online no prescription tramadol overdose treat - buy tramadol online overnight shipping
buy tramadol online buy tramadol online florida - buy tramadol from usa
generic carisoprodol carisoprodol 350 mg codeine - use of carisoprodol 350 mg
order tramadol online mastercard tramadol withdrawal time frame - tramadol online no prescription overnight delivery
xanax online xanax effects 2mg - generic xanax s 900
buy tramadol online tramadol normal dose - buy tramadol online us
buy tramadol online tramadol not addictive - buy tramadol online without rx
cialis cost cheap legal cialis - buy cialis cheap online
buy cialis online buy cialis online with prescription - cialis 60 tablet
xanax online 10 mg xanax high - lexapro generic xanax
xanax online xanax side effects uses - xanax vs vicodin
buy tramadol online tramadol hcl 50 mg dogs - tramadol online yahoo
tramadol online tramadol 50 mg opiate - tramadol withdrawal with vicodin
http://buytramadolonlinecool.com/#91646 buy tramadol american express - generic tramadol no prescription cod
lorazepam drug ativan side effects long term - ativan withdrawal signs and symptoms
buy discount tramadol tramadol 100mg info - order tramadol online safely
http://bayshorechryslerjeep.com/#3880 difference between generic xanax regular - order xanax online canada
Post a Comment