Pic Basic help


Closed Thread
Results 1 to 4 of 4

Thread: Pic Basic help

  1. #1
    Join Date
    Apr 2008
    Location
    Gainesville, VA
    Posts
    15

    Default Pic Basic help

    OK, this is probably really simple but I can't seem to make it work. I'm using a IF THEN statement like this: IF (variable) = (a number) THEN (Label)
    Label: some code
    END IF
    When I try to compile, the error message I get is END IF without a matching IF---THEN
    Basically, what I am trying to do is jump out of a loop to "Label" if the variable is a specific number.
    Reading the PICBASIC compiler manual, I can't see what I'm doing wrong. Thanks for any help.
    Klaus

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Code:
    Start:        
            IF MyVar=9 THEN
                LCDOUT $FE,1,"How's Santa today?"
                ELSE
                    GOSUB PassGoAndClaim200Bucks
                ENDIF
            
            IF MyVar=8 THEN
                PAUSE 500
                LCDOUT $FE,1,"Doh!"
                STOP
                ENDIF            
                
            IF MyVar=7 THEN WhoLetTheDogsOut
          
            GOTO Start
            '
            '
            '
    PassGoAndClaim200Bucks:
            '
            '   Plah Plah Plah
            '
            RETURN 
            '
            '
            '
    WhoLetTheDogsOut:        
            '
            '   Woo... Woo... Woo
            '
            GOTO Start
    Make sure you didn't forgot a ENDIF somewhere in your code while editing it... yeah it happen
    Last edited by mister_e; - 20th April 2008 at 18:45. Reason: typo... sure there's still :D
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default

    Hi Klaus,
    When you have a one-line IF statement you don't use EndIf. So simply:
    Code:
    If A = B Then myLabel
    should do it.

    /Henrik.

  4. #4
    Join Date
    Apr 2008
    Location
    Gainesville, VA
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    Thanks very much. Leaving out the ENDIF worked.

Similar Threads

  1. Sending Commands from Visual Basic about IR to Pic
    By tne_de in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 29th April 2009, 06:09
  2. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  3. using AND as an IF statement
    By dw_pic in forum mel PIC BASIC
    Replies: 27
    Last Post: - 8th June 2006, 18:05
  4. vb6 to pic basic
    By Darrenmac in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 19th December 2005, 01:56
  5. The Ultimate PIC Basic
    By picnaut in forum PBP Wish List
    Replies: 4
    Last Post: - 9th November 2004, 22:10

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts