Array and IF - THEN


Results 1 to 10 of 10

Threaded View

  1. #1
    Join Date
    Dec 2007
    Location
    Finland
    Posts
    191

    Post Array and IF - THEN

    I tried to search info about how to handle input strings (arrays) and do selections based on what was received to an array, but not so good success. Most probably I don't know what are the right key words..., but anyway.
    Below is sample code, which is very similar that I have in the program. Only difference is that I use 6 bytes instead of 4. Code is working OK.

    Question is, can I do this more sophisticated way?
    I have lots of similar IF - THEN and I really want to know if there would be a more simple way to do this.

    Code:
    <code><font color="#000000">LED         <b>VAR </b>PortB.0
    Data_Array  <b>VAR BYTE </b>[4]
    
    Mainloop:
        <b>DEBUGIN </b>1000, Mainloop, [<b>STR </b>Data_Array\4]
        <b>IF </b>Rele_Array[0] = <font color="#FF0000">&quot;A&quot; </font><b>THEN
            IF </b>Rele_Array[1] = <font color="#FF0000">&quot;B&quot; </font><b>THEN
                IF </b>Rele_Array[2] = <font color="#FF0000">&quot;C&quot; </font><b>THEN
                    IF </b>Rele_Array[3] = <font color="#FF0000">&quot;1&quot; </font><b>THEN
                        HIGH </b>LED                    <font color="#000080"><i>'If received ABC1
                        </i></font><b>PAUSE </b>1000                  <font color="#000080"><i>'then turn LED on
                        </i></font><b>LOW </b>LED                     <font color="#000080"><i>'for 1s and return
                        </i></font><b>GOTO </b>Mainloop               <font color="#000080"><i>'to Mainloop
                    </i></font><b>ENDIF
                    IF </b>Rele_Array[3] = <font color="#FF0000">&quot;2&quot; </font><b>THEN
                        HIGH </b>LED                    <font color="#000080"><i>'If received ABC2
                        </i></font><b>PAUSE </b>2000                  <font color="#000080"><i>'then turn LED on
                        </i></font><b>LOW </b>LED                     <font color="#000080"><i>'for 2s and return
                        </i></font><b>GOTO </b>Mainloop               <font color="#000080"><i>'to Mainloop
                    </i></font><b>ENDIF
                ENDIF
            ENDIF
        ENDIF
    
        END
    
    </b></code>
    BR,
    -Gusse-
    Last edited by Gusse; - 22nd January 2010 at 18:54.

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