Gusse
- 22nd January 2010, 18:42
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><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">"A" </font><b>THEN
IF </b>Rele_Array[1] = <font color="#FF0000">"B" </font><b>THEN
IF </b>Rele_Array[2] = <font color="#FF0000">"C" </font><b>THEN
IF </b>Rele_Array[3] = <font color="#FF0000">"1" </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">"2" </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-
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><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">"A" </font><b>THEN
IF </b>Rele_Array[1] = <font color="#FF0000">"B" </font><b>THEN
IF </b>Rele_Array[2] = <font color="#FF0000">"C" </font><b>THEN
IF </b>Rele_Array[3] = <font color="#FF0000">"1" </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">"2" </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-