Can not get my IF THEN statement to work


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Nov 2004
    Location
    Saskatchewan Canada
    Posts
    189


    Did you find this post helpful? Yes | No

    Default

    If you really are using PicBasic and NOT PicBasic Pro then any ENDIF and ELSE statements won't work for you. Keep that in mind when writing your program. You need to work around that. Some of the solutions presented won't work "as is" for that reason.

    Rhatidbwoy has the right idea in his example.

    Bart

  2. #2
    Join Date
    Aug 2005
    Location
    Houston, TX
    Posts
    43


    Did you find this post helpful? Yes | No

    Default

    I have never been able to get an "If - Then" command to work using more that one condition in PIC Basic. That is no A and B. Only A, then another question.

    If I want to test a as 10 plus b at 20 for calling x:
    loop:
    if a = 10 then isb
    loopb:

    isb:
    if b = 20 then x
    goto loopb

  3. #3
    Join Date
    Nov 2004
    Location
    Saskatchewan Canada
    Posts
    189


    Did you find this post helpful? Yes | No

    Default

    AND and OR are valid PicBasic commands used with IF/THEN and the proper syntax is "IF A=1 AND B=2 THEN" so if your's aren't working I don't think that is the reason. I'm just not good enough at reading other people's code to sort out the why.

    Sorry.

    Bart

  4. #4
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    shouldnt the line "if B6 = $31 and B7 < $35 then twenf" read:

    if B6 = $31 and B7 < $35 then GOTO twenf ?

    or is the GOTO not required when using an if statement?

  5. #5
    dw_pic's Avatar
    dw_pic Guest


    Did you find this post helpful? Yes | No

    Default

    To my knowledge, "with picbasic, not pro"

    The picbasic compiler will see the added "goto" as a undeclared symbol and choke on it.

    the action is a goto, but the syntax is

    if X = true then label

    dw

  6. #6
    Rhatidbwoy's Avatar
    Rhatidbwoy Guest


    Did you find this post helpful? Yes | No

    Default

    The problem that I have with the statement is that when it is executed to the goto from the IF...THEN I used poke. When writing to a VAR I do not need the poke, but when I need to write to a address on the chip, per-say, that is when I would use the poke or peek. Example: POKE $86,0 for writing to the chip ;

    (NOT CORRECT)
    twenf:
    poke B6,$32: poke B7,$35:goto cs

    (CORRECT)
    twenf:
    B6 = $32 : B7 = $35 : goto cs

    OR

    twenf:
    B6 = $32
    B7 = $35
    goto cs

Similar Threads

  1. END Statement
    By jderson in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 9th November 2008, 14:48
  2. How do I get DATA @ to work with a 18F452?
    By jessey in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 2nd February 2006, 10:35
  3. blink.bas help cant make any 18f's work
    By Bonxy in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 13th December 2004, 21:28
  4. Pin RA4 doesn't work
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 0
    Last Post: - 15th July 2004, 12:03
  5. Interrupt Problem
    By FrankM in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 20th June 2004, 15:53

Members who have read this thread : 0

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