Announcement

Collapse
No announcement yet.

If/Then's and Elses

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • If/Then's and Elses

    Trying to check three switches and given two possibilities, to execute jumping to labels or serial command. Throwing errors.
    Is it that I can't 'else' to the serial command by itself? I'm sending the switch info wirelessly and switches all work with just a 'then' to a label.


    Commented code:

    switch: serin portc.3,2,b1 'remote send state of switches (wireless)
    pause 10
    if b1=64 then
    up '#1 switch pressed
    else ' 'else' ...
    portc.1,2,[126,14,0,0,0,255,242,239] 'send this 'pause' to audio player
    endif
    pause 10
    if b1=32 then
    center '#2 switch pressed
    else ' 'else'...
    portc.1,2,[126,14,0,0,0,255,242,239] 'send pause to audio player
    endif
    pause 10
    if b1=16 then
    down '#3 switch pressed
    else ' 'else'...
    portc.1,2,[126,14,0,0,0,255,242,239] 'send pause to audio player
    endif
    goto switch

  • #2
    Show me something from each of the called routines Where is "up" and "center" and "down"? How are you returning from these routines?
    Dave Purola,
    N8NTA
    EN82fn

    Comment


    • #3
      This is the rest:


      up:SEROUT portc.1,2,[126,3,0,0,1,255,252,239]
      SEROUT portc.1,2,[126,3,0,0,1,255,252,239]
      pause 100

      for p0=210 to b3 step -1
      pulsout porta.2,p0
      pause 20-p0/100
      pulsout porta.2,p0
      pause 20-p0/100
      next p0
      if b3=135 then
      b3=210
      else
      b3=b3+b3
      endif
      goto switch

      center: serout portc.1,2,[126,3,0,0,2,255,251,239]
      serout portc.1,2,[126,3,0,0,2,255,251,239]

      for b2=1 to 2
      for p0=130 to 160 step 5
      pulsout porta.2,p0
      pause 20-p0/100
      next p0

      for p0=160 to 135 step -5
      pulsout porta.2,p0
      pause 20-p0/100
      next p0
      next b2
      goto switch


      down:SEROUT portc.1,2,[126,3,0,0,3,255,250,239]
      SEROUT portc.1,2,[126,3,0,0,3,255,250,239]
      pause 100
      for p0=135 to 210 step 1
      pulsout porta.2,p0
      pause 20-p0/100
      pulsout porta.2,p0
      pause 20-p0/100
      next p0
      goto switch

      Comment


      • #4
        Is it that I can't 'else' to the serial command by itself?
        Code:
        if b1=64 then
        up '#1 switch pressed
        else ' 'else' ...
        portc.1,2,[126,14,0,0,0,255,242,239] 'send this 'pause' to audio player    <----What's this?
        endif
        You seem to be missing the actual SEROUT command...

        Comment


        • #5
          That's true Henrik but had commented that out so where I was throwing the errors was the 'if/then/else' statements. In that initial post of code the errors that come up are (on all 3 'ifs, etc.') are: "ELSE without a matching IF...THAN" and "ENDIF without a matching IF...THEN"

          Your "what's this?" question above is a serial pause command I'm sending to an MP3 chip.

          Comment


          • #6
            Okay, cleared up the if/thens. Had the 'then' label on the same line as the 'if''.
            Now though, all the labels places (example: up:SEROUT portc.1,2,[126,3,0,0,1,255,252,239] ) are throwing the error: "Redefinition of LABEL ('up' for instance)"

            Comment


            • #7
              Got it. Needed a 'goto' on the label.

              Comment

              Working...
              X