IF ....THEN.... problems


Results 1 to 17 of 17

Threaded View

  1. #2
    Join Date
    May 2010
    Location
    Chile
    Posts
    25


    Did you find this post helpful? Yes | No

    Default Re: IF ....THEN.... problems

    You've got a redundancy in your code (maybe on purpose),

    First you activate the timer = 1 flag, and in the next line of code you put an " IF timer = 1..."

    Also the second IF THEN ELSE is inside the first IF THEN, try separating them.

    Try using indent in your coding to see in a better way your routine operation

    this is your code...commented
    Code:
    begin:
    pause 100
    IF timer = 1 AND relay = 1 THEN
        pause 500
        timer = 0 'turn off timer'
        PAUSE 1000
        portb.1 = 0
        timer = 1 'turn on timer'               '--turned timer = 1 
    
        IF timer = 1 AND relay = 1 THEN   '--inside first loop? move it out.  Timer already turned 1 on previous line, so is always true for that part
            pause 500
            timer = 0 'turn off timer'
            pause 1000
            portb.1 = 1
            pause 1000
            timer = 1 'turn on timer'
        ENDIF
    ENDIF
    Last edited by El_AMPo; - 21st February 2011 at 15:31.
    "If at first doesn't work, kicking it wont help either"

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