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.
........................................................................
learning puppybasic
1 of 15
an intro to puppybasic
chapter 2: learning puppybasic
........................................................................
........................................................................
learning puppybasic
2 of 15
when learning any programming language, the first thing to look at is a
good tutorial, if one is available. most tutorials will include some
variation of a "hello world" program, or a program to simply make the
computer say "hello, world!" on the screen. the second thing to look at
when learning a new language is program examples, where "hello, world"
might be the most simple.
........................................................................
........................................................................
learning puppybasic
3 of 15
true to the name, b.a.s.i.c makes pretty easy work of this:
10 PRINT "hello, world!" ______________________________________________
20 END _hello, world!________________________________
______________________________________________
______________________________________________
______________________________________________
______________________________________________
........................................................................
........................................................................
learning puppybasic
4 of 15
that was the old way, that is, every line required a line number. in
puppybasic, line numbers really don't work, and aren't needed.
........................................................................
........................................................................
learning puppybasic
5 of 15
here is a more "modern" version of the code:
PRINT "hello, world!"
END
not much difference there, of course you'll need a new way to reference
a position inside the code, but puppybasic has several, don't worry.
........................................................................
........................................................................
learning puppybasic
6 of 15
the PRINT statement, which should probably be called ECHO, like it is in
dos, "prints" to the screen. of course, before everyone had crt's (or
lcd's) attached to their computers, the "screen" was a teletype, or an
electric printer-keyboard combo similar enough to a typewriter, so maybe
"print" wasn't too odd a thing to call it.
........................................................................
........................................................................
learning puppybasic
7 of 15
the statement for printing to a printer incidentally, is LPRINT, of
course this is essentially part of a dos system; not only does windows
sometimes create problems when using LPRINT, but without windows, LPRINT
will not print to some newer models of printers (i saw lexmark abandon
pure-dos compatibility first, though it could have been someone else)
and of course, will not print to usb printers. (it is possible to access
some usb devices from dos without running windows. it is very, very
tricky.)
........................................................................
........................................................................
learning puppybasic
8 of 15
the END statement simply ends the program. if there is code after the
END statement, it will not run unless you specifically tell another part
of the program to go there.
........................................................................
........................................................................
learning puppybasic
9 of 15
if you tell the computer to PRINT again, it will print on the next
line... so the following code:
PRINT "hello, world!"
PRINT "how are you?"
END
_________________________________
would end up like this on the screen: _hello, world!___________________
_how are you?____________________
_________________________________
_________________________________
........................................................................
........................................................................
learning puppybasic
10 of 15
if you don't want it to go to the next line, try putting a semicolon
outside the quote marks to the line you want to add to:
PRINT "hello, world!";
PRINT "how are you?"
______________________________________
which will instead produce this: _hello, world!how are you?____________
______________________________________
you can add spaces as you like. ______________________________________
______________________________________
______________________________________
........................................................................
........................................................................
learning puppybasic
11 of 15
you may end up with a lot of "hello" on one screen, or you may simply
want to start fresh. this command:
CLS
stands for "clear screen" and is a common way to start a program.
CLS
PRINT "hello!"
but you want more fun to really appreciate programming. let's add color.
........................................................................
........................................................................
learning puppybasic
12 of 15
basic and puppybasic are not limited to text, but text-related functions
are worth covering first, since they're usually easier to code and since
you can't get away from them all, even if you're writing a gui util.
changing the color is easy enough, if you know how.
let's try this:
_______________________________________________________
CLS _BLUE!_________________________________________________
COLOR 1 _______________________________________________________
PRINT "BLUE!" _______________________________________________________
_______________________________________________________
........................................................................
........................................................................
learning puppybasic
13 of 15
and that's what that does. colors are represented by numbers, and in the
default text-only mode there are about sixteen of them.
here's a table:
0
black 1 blue 2 green 3 cyan 4 red 5 magenta 6 brown 7 white
8 9 10 11 12 13 14 15
grey l.blue l.green l.cyan l.red l.magenta yellow bright-white
........................................................................
........................................................................
learning puppybasic
14 of 15
you can even change colors before you go to the next letter:
COLOR 2
PRINT "h"; ____________________________________________________________
COLOR 3 _hello______________________________________________________
PRINT "e"; ____________________________________________________________
COLOR 5 ____________________________________________________________
PRINT "l"; ____________________________________________________________
COLOR 4 ____________________________________________________________
PRINT "l"; ____________________________________________________________
COLOR 1 ____________________________________________________________
PRINT "o" ____________________________________________________________
........................................................................
........................................................................
learning puppybasic
15 of 15
so you dont get confused when you see people use it, PRINT without any
string or number or variable just prints a blank line (or stops adding
to the end of a PRINT statement with a semicolon on the end.)
-= end of chapter 2 =-
........................................................................
an intro to puppybasic (chapter 2)
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. 02- learning puppybasic
Subscribe to:
Post Comments (Atom)
30 comments:
buy tramadol online buy-tramadol - purchase tramadol online no prescription
buy tramadol online tramadol 50mg street price - buy tramadol overnight delivery no prescription
xanax generic online rx no prescription xanax - generic xanax not working
xanax online xanax withdrawal like - xanax overdose alcohol
can you buy tramadol online legally best place order tramadol online - buy tramadol online legit
buy tramadol online order cheap tramadol cod - tramadol for dogs long term
xanax online xanax effects pregnancy - xanax generic yellow
buy carisoprodol 350 mg carisoprodol generic soma - 350 mg of carisoprodol
carisoprodol 350 mg carisoprodol 350 mg many get high - carisoprodol detection drug test
buy carisoprodol carisoprodol drug type - carisoprodol drug category
buy tramadol online tramadol hcl contents - buy tramadol powder
buy tramadol online tramadol hcl reviews - buy tramadol online visa
generic xanax high off xanax xr - xanax side effects chest pain
xanax price xanax generic walmart - xanax come up drug test
buy cialis online illegal to buy cialis online - cialis online with paypal
cialis online buy cialis online without rx - generic cialis yahoo answers
buy cialis online cialis coupon program - cialis online 5mg
xanax online xanax and high - xanax strengths
http://landvoicelearning.com/#57594 tramadol versus ultram - buy tramadol no prescription overnight
buy tramadol buy tramadol online yahoo - tramadol overdose dog
learn how to buy tramdadol ordertramadolonline - tramadol hcl and acetaminophen
http://landvoicelearning.com/#74967 tramadol no prescription overnight - buy tramadol online in florida
http://landvoicelearning.com/#74967 tramadol dosage men - tramadol dosage in canine
http://buytramadolonlinecool.com/#56411 tramadol hcl 50mg narcotic - tramadol 50 mg itching
order tramadol online mastercard tramadol 100 mg sandoz - tramadol klonopin
generic ativan lorazepam online no prescription - ativan overdose stories
ways to buy ativan online lorazepam 1 mg n1 - ativan side effects hives
generic tramadol online buy tramadol 100mg online - 200 mg tramadol high
buy tramadol online buy tramadol online no prescription mastercard - tramadol online pharmacy no prescription
http://bayshorechryslerjeep.com/#6828 one time xanax drug test time - xanax drug test time
Post a Comment