Beginner Help with code
TonyA
Posts: 226
I'm just starting to look at SPIN and working through the Propeller manual tutorial and am trying to complile and download this bit of code:
When I try to compile I get a message "Expected Expression" and NES0_UP is highlighted.
Could anyone offer advice?
Thanks in advance.
Post Edited (TonyA) : 7/3/2007 12:42:37 AM GMT
OBJ game_pad : "gamepad_drv_001.spin" 'instantiating the gamepad driver object PUB main game_pad.start 'referencing the gamepad driver's start method game_pad.read 'referencing the gamepad driver's read method if (game_pad.button(NES0_UP) 'referencing the gamepad driver's button method. DIRA[noparse][[/noparse]7]~~ 'If nes "up" button is pressed then make pin (7) an output 'run the toggle loop. Repeat !OUTA[noparse][[/noparse]7] 'repeat the toggle process waitcnt(3_000_000 + cnt) 'timer
When I try to compile I get a message "Expected Expression" and NES0_UP is highlighted.
Could anyone offer advice?
Thanks in advance.
Post Edited (TonyA) : 7/3/2007 12:42:37 AM GMT
Comments
When I added the CON block (see below), and then added another bracket;·(NES0_UP)), she complied.
Thanks.
Post Edited (TonyA) : 7/3/2007 1:34:27 AM GMT
So it's:
game_pad#NES0_UP
I was going by this (in the comment of the gamepad_drv_001) where it says;
test if a specific button is down with:
' object_name.button(button_id)
' returns TRUE or FALSE
The button id is: NES0_UP
I'm just learning about OOP and programming (Outside of PBasic and PicBasic)·in general, but was wondering why I had to add the constant to the code of my top object when I am importing the driver?
Also, would this still compile if incorrect?
if (game_pad.button(NES0_UP)) 'driver's button method.
Thanks again.
Post Edited (TonyA) : 7/3/2007 2:29:33 AM GMT
It does compile.
Thanks.