I need PBASIC 2.5 help.
nightrider
Posts: 9
Hello all,
I'm learning PBASIC 2.5 from a book called PROGRAMMING AND CUSTOMIZING THE BASIC STAMP COMPUTER and I ran into this situation.· The following code produces the output under it:
code
' {$STAMP BS2}
' {$PBASIC 2.5}
_x· VAR Byte
_y· VAR Byte
_z· VAR Byte
_area VAR Word
_x = 20
_y = 30
B0 = 155
B1 = 220
W2 = B0 + B1
_area = _x*_y· 'solve the area
DEBUG "the Area is ", DEC _area, "sq ft."
DEBUG CR, ? B0, ? B1, ? B2, ? W2
END
======================================
OUTPUT:
the Area is 600sq ft.
B0 = 88
B1 = 2
B2 = 20
W2 = 375
=====================================
My questions are:
-why is B1 = 2 when I declared it '220'?
-why is B2 = 20 when I didn't load it with any values?
-W2 is giving me the correct sum, but why are the B variables displaying strange results?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thank you,
Alex Cordero
San Diego, Ca.
"what?"
robots: AIBO ERS-220, Robosapien, Roomba, Boe-bot (basic), a bunch of other little robots and toys.
"Fill your boots, man!"
-Irish saying
I'm learning PBASIC 2.5 from a book called PROGRAMMING AND CUSTOMIZING THE BASIC STAMP COMPUTER and I ran into this situation.· The following code produces the output under it:
code
' {$STAMP BS2}
' {$PBASIC 2.5}
_x· VAR Byte
_y· VAR Byte
_z· VAR Byte
_area VAR Word
_x = 20
_y = 30
B0 = 155
B1 = 220
W2 = B0 + B1
_area = _x*_y· 'solve the area
DEBUG "the Area is ", DEC _area, "sq ft."
DEBUG CR, ? B0, ? B1, ? B2, ? W2
END
======================================
OUTPUT:
the Area is 600sq ft.
B0 = 88
B1 = 2
B2 = 20
W2 = 375
=====================================
My questions are:
-why is B1 = 2 when I declared it '220'?
-why is B2 = 20 when I didn't load it with any values?
-W2 is giving me the correct sum, but why are the B variables displaying strange results?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thank you,
Alex Cordero
San Diego, Ca.
"what?"
robots: AIBO ERS-220, Robosapien, Roomba, Boe-bot (basic), a bunch of other little robots and toys.
"Fill your boots, man!"
-Irish saying
Comments
Good Luck , Dave.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ D Rat
The scratchpad ram does not exist on the BS2 and is only 64 bytes on the BS2e and BS2sx.
NOTE:
it may help to know that my programming experience is HTML/Javascript and Perl. I have no experience is writing code to access hardware. So I don't know how Pbasic communicates with BS2.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thank you,
Alex Cordero
San Diego, Ca.
"what?"
robots: AIBO ERS-220, Robosapien, Roomba, Boe-bot (basic), a bunch of other little robots and toys.
"Fill your boots, man!"
-Irish saying
Jeff T.
The reason for both is that the VAR declaration came later in the development of the PBasic editor/compiler than the simple predefined names and, when the VAR declaration was added, the other was left in for compatibility reasons.