Help with Maxim Ibutton "IF THEN ELSE" statements please


Closed Thread
Results 1 to 39 of 39

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Help with Maxim Ibutton "IF THEN ELSE" statements please

    Hi,
    Since your IF-THEN statements are actually GOTOs (if evaluated true) all you need to do is add GOSUB (or GOTO) WRONG after the three IF statements.
    Code:
    IF Serial[1]=$15 AND Serial[2]=$D3 AND Serial[3]=$7D AND Serial[4]=$16 AND Serial[5]=$00 AND Serial[6]=$00 THEN correct1    '<----This will GOTO correct1
    IF Serial[1]=$68 AND Serial[2]=$36 AND Serial[3]=$4F AND Serial[4]=$17 AND Serial[5]=$00 AND Serial[6]=$00 THEN correct2
    IF Serial[1]=$1E AND Serial[2]=$1A AND Serial[3]=$2C AND Serial[4]=$17 AND Serial[5]=$00 AND Serial[6]=$00 THEN correct3
    GOSUB WRONG
    GOTO mainloop
    Now the WRONG subroutine will only execute if none of the three IF statements evalutate true.

    /Henrik.

  2. #2
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237


    Did you find this post helpful? Yes | No

    Default Re: Help with Maxim Ibutton "IF THEN ELSE" statements please

    Henrik

    You mean :-

    Now the WRONG subroutine will only execute if none of the three IF statements evalutate FALSE.

    Not near the units so cant try at moment !

    Thank you for reading

  3. #3
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: Help with Maxim Ibutton "IF THEN ELSE" statements please

    Quote Originally Posted by andybarrett1 View Post
    Henrik

    You mean :-

    Now the WRONG subroutine will only execute if none of the three IF statements evalutate FALSE.

    Not near the units so cant try at moment !

    Thank you for reading
    No he means:-

    Now the WRONG subroutine will only execute if ALL of the three IF statements evalutate FALSE.
    Last edited by EarlyBird2; - 8th May 2014 at 09:31.

  4. #4
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237


    Did you find this post helpful? Yes | No

    Default Re: Help with Maxim Ibutton "IF THEN ELSE" statements please

    Quote Originally Posted by EarlyBird2 View Post
    No he means:-

    Now the WRONG subroutine will only execute if ALL of the three IF statements evalutate FALSE.
    So its like a :-

    IF NOT THEN

    Sorry for being so dim.....Thank you for help !

  5. #5
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: Help with Maxim Ibutton "IF THEN ELSE" statements please

    Not what was meant.

    All you need to do is change this

    else gosub wrong
    endif

    to this

    gosub wrong

    in your code

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Help with Maxim Ibutton "IF THEN ELSE" statements please

    Hi,
    Now the WRONG subroutine will only execute if none of the three IF statements evalutate FALSE
    No, as have been said. If the first condition evalutes TRUE the execution will GOTO correct1 and therefor bypass the GOSUB WRONG statement. Same thing if the second or third condition evalutes TRUE. However, if none of the three conditions evalutes true the GOSUB WRONG will execute. Remember that the way you have your IF statment written it'll issue a GOTO, not GOSUB so make sure that your correct1, 2, 3 routines does not end with a RETURN.

    That is neat! Although I do not like using goto statements as they can make the program logic difficult to follow.
    I totally agree, GOTOs can lead to some real mess but sometimes it's the easy way.....and there's almost always more than one way to do what one wants.

    /Henrik.

  7. #7
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: Help with Maxim Ibutton "IF THEN ELSE" statements please

    In Scunthorpe to see the BOS plant?

    I am amazed but thinking about it I can not think of any other reason to come here.

    Hope you did not travel far!

  8. #8
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237


    Did you find this post helpful? Yes | No

    Default Re: Help with Maxim Ibutton "IF THEN ELSE" statements please

    Will play about with it later...

    Am understanding more now

    Thank you

  9. #9
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: Help with Maxim Ibutton "IF THEN ELSE" statements please

    Henrik,

    That is neat! Although I do not like using goto statements as they can make the program logic difficult to follow.

Similar Threads

  1. Replies: 0
    Last Post: - 14th November 2013, 03:32
  2. Replies: 3
    Last Post: - 15th October 2012, 08:06
  3. Replies: 8
    Last Post: - 3rd March 2011, 22:20
  4. Replies: 5
    Last Post: - 28th February 2011, 15:33
  5. Replies: 1
    Last Post: - 16th February 2005, 20:05

Members who have read this thread : 0

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

Tags for this Thread

Posting Permissions

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