Shop OBEX P1 Docs P2 Docs Learn Events
PropBasic coding and compiling issue — Parallax Forums

PropBasic coding and compiling issue

bsnutbsnut Posts: 521
edited 2010-12-21 13:46 in Propeller 1
I have some issues that PropBasic is not compiling simple code such as this
if Switch1 = 1 AND Switch = 1 then Count_up

and it gives me this error "INVALID NUMBER OF PARAMETERS You have too few or too many parameters given.

I don't understand why I am getting this error and can someone tell me why this happening.
Below is my code.
DEVICE          P8X32A, XTAL1, PLL16X
XIN             5_000_000


' ----------------------------------------------------------------------
' Constants
' ----------------------------------------------------------------------


' ----------------------------------------------------------------------
' I/O Pins
' ----------------------------------------------------------------------
Light PIN 16 OUTPUT
Switch pin 12 input
Switch1 pin 13 input
Switch2 pin 14 input
' ----------------------------------------------------------------------
' Shared (hub) Variables (Byte, Word, Long)
' ----------------------------------------------------------------------


' ----------------------------------------------------------------------
' Shared (hub) Data (DATA, WDATA, LDATA, FILE)
' ----------------------------------------------------------------------


' ----------------------------------------------------------------------
' TASK Definitions
' ----------------------------------------------------------------------


' ----------------------------------------------------------------------
' Cog Variables (Long only)
' ----------------------------------------------------------------------
northcount var long

' ----------------------------------------------------------------------
' SUB/FUNC Definitions
' ----------------------------------------------------------------------


' ======================================================================
  PROGRAM Start
' ======================================================================

Start:
if Switch = 1 then Toggle_onoff
if Switch1 = 1 AND Switch = 1 then Count_up
if Switch2 = 1 then Reset_Count
GOTO Start

Toggle_onoff:
if northcount > 4 then Start
TOGGLE Light
PAUSE 1000
GOTO Start

Count_up:
inc northcount
GOTO Start

Reset_Count:
dec northcount
GOTO Start
  END

Comments

  • VonSzarvasVonSzarvas Posts: 3,523
    edited 2010-12-21 03:08
    would it solve with this change?
    if Switch = 1 then 
         
        GOTO Toggle_onoff
         if Switch1 = 1 then Count_up
    
    endif
    
    if Switch2 = 1 then Reset_Count
    
    
  • VonSzarvasVonSzarvas Posts: 3,523
    edited 2010-12-21 03:11
    ... actually, you might have some other problems with your logic:

    As I can see, the jump to "Toggle_onoff" will always result in sending back to "Start", so you will never get the chance to evaluate Switch1 (either in your original code or in my version).
  • BeanBean Posts: 8,129
    edited 2010-12-21 05:49
    You need to put each condition on a seperate line.
    IF Switch1 = 1 AND
      Switch = 1 THEN Count_up
    

    Bean
  • JonnyMacJonnyMac Posts: 9,208
    edited 2010-12-21 11:32
    I'm with Max and wonder if this is what you actually meant to do:
    Start
      IF Switch = 1 THEN
        IF Switch1 = 0 THEN
          TOGGLE_ONOFF
        ELSE
          COUNT_UP
        ENDIF
      ENDIF
    
      IF Switch2 = 1 THEN
        RESET_COUNT
      ENDIF
    
      GOTO Start
    
  • bsnutbsnut Posts: 521
    edited 2010-12-21 13:46
    Jon, Bean, and Max the ways that you all shown me will work and I didn't think of trying that at all.

    I am so used to the Basic Stamp why of coding and I was trying to see if it was doable(would compile), that's why I posted the code. I normally do small test code to check things like this and hope I didn't confuse anyone

    Thanks for the help and you all answered my one big question that I had. More questions may come done the pike as I am learning a different way to coded my programs.
Sign In or Register to comment.