In SX Microcontrollers, SX/B Compiler and SX-Key Tool, JonnyMac wrote: You're right, which is why I don't use the LOOKDOWN approach in my programs that accept serial commands. While it may seem verbose, checking the characters as they come in prevents issues. For example, our FC-4 fader board uses this bit of code for processing commands from the master: [code]Main: char = RX_BYTE ' wait for header IF char <> "!" THEN Main char = RX_BYTE ToUpper IF char <> "F" THEN Main char = RX_BYTE ToUpper IF char <> "C" THEN Main char = RX_BYTE IF char <> "4" THEN Main Check_Addr: char = RX_BYTE ' rx addr allCall = No ' clear global request IF char = CmdAll THEN ' all call requested? allCall = Yes ' yes, set flag GOTO Get_Cmd ' and skip ID check ENDIF addr = %00 ' clear old setting addr.0 = ~A0 ' get low bit of address addr.1 = ~A1 ' get high bit of address IF char <> addr THEN Main ' validate Get_Cmd: char = RX_BYTE ToUpper ' rx command byte IF char = "V" THEN Show_Version IF char = "G" THEN Get_Status IF char = "L" THEN Set_Level IF char = "S" THEN Set_All IF char = "P" THEN Preset_All IF char = "A" THEN All_On IF char = "D" THEN Digital_Control IF char = "X" THEN Reset_All IF char = "F" THEN Fader IF char = "C" THEN Cross_Fade GOTO Main[/code] It may seem verbose, but as the style is close to the assembly output it doesn't take a lot of code, and it's quite easy to add or disable features while testing. ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=252933#m252963 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)