Hi all,
I often use SELECT/CASE over IF/ENDIF.
But in a few situations when the select/case has more complex items to handle. I have found that it seems to get bogged down more then a conventional If/Endif format.
To the point that it will refuse to work at all. Even though it checks out fine.
The below layout shows the two formats I have used.
This piece of code is used to select a scrolling message that will be displayed by an OLED, receiving data from an RF link.
Using the CASE format, 3 of 10 times, it won't display the scrolling message at all.
While it always does with the IF/ENDIF format. This is not the first time I have encountered this behavior, using SELECT/CASE, under similar circumstances.
Plus.The CASE format also makes the program 60bytes larger, than with the IF format.
Most of these messages(not included)are up to 44 characters.
Any idea why this happens?
I often use SELECT/CASE over IF/ENDIF.
But in a few situations when the select/case has more complex items to handle. I have found that it seems to get bogged down more then a conventional If/Endif format.
To the point that it will refuse to work at all. Even though it checks out fine.
The below layout shows the two formats I have used.
This piece of code is used to select a scrolling message that will be displayed by an OLED, receiving data from an RF link.
Using the CASE format, 3 of 10 times, it won't display the scrolling message at all.
While it always does with the IF/ENDIF format. This is not the first time I have encountered this behavior, using SELECT/CASE, under similar circumstances.
Plus.The CASE format also makes the program 60bytes larger, than with the IF format.
Most of these messages(not included)are up to 44 characters.
Any idea why this happens?
Code:
scroll_message_selector:
if rx_data=%00000001 or rx_data=%00001101 then serout b.2,n2400_16,(254,208,"")endif ;44 characters max.
if rx_data=%00000010 or rx_data=%00010000 then serout b.2,n2400_16,(254,208,"")endif
if rx_data=%00000011 or rx_data=%00001111 then serout b.2,n2400_16,(254,208,"")endif
if rx_data=%00000100 or rx_data=%00001110 then serout b.2,n2400_16,(254,208,"")endif
if rx_data=%00000101 or rx_data=%00001100 then serout b.2,n2400_16,(254,208,"")endif
if rx_data=%00000110 or rx_data=%00001011 then serout b.2,n2400_16,(254,208,"")endif
if rx_data=%00000111 then serout b.2,n2400_16,(254,208,"")endif
if rx_data=%00001000 then serout b.2,n2400_16,(254,208,"")endif
if rx_data=%00001001 then serout b.2,n2400_16,(254,208,"")endif
if rx_data=%00001010 then serout b.2,n2400_16,(254,208,"")endif
if rx_data=%00010001 then serout b.2,n2400_16,(254,208,"")endif
if rx_data=%00010010 then serout b.2,n2400_16,(254,208,"")endif
if rx_data=%00010011 then serout b.2,n2400_16,(254,208,"")endif
if rx_data=%00010100 then serout b.2,n2400_16,(254,208,"")endif
if rx_data=%00010101 then serout b.2,n2400_16,(254,208,"")endif
if rx_data=%00010110 then serout b.2,n2400_16,(254,208,"")endif
if rx_data=%00010111 then serout b.2,n2400_16,(254,208,"")endif
if rx_data=%00011000 then serout b.2,n2400_16,(254,208,"")endif ;
return
scroll_message_selector:
select case rx_data
case %00000001,%00001101: serout b.2,n2400_16,(254,208,"") ;44 characters max.
case %00000010,%00010000: serout b.2,n2400_16,(254,208,"")
case %00000011,%00001111: serout b.2,n2400_16,(254,208,"")
case %00000100,%00001110: serout b.2,n2400_16,(254,208,"")
case %00000101,%00001100: serout b.2,n2400_16,(254,208,"")
case %00000110,%00001011: serout b.2,n2400_16,(254,208,"")
case = %00000111: serout b.2,n2400_16,(254,208,"")
case = %00001000: serout b.2,n2400_16,(254,208,"")
case = %00001001: serout b.2,n2400_16,(254,208,"")
case = %00001010: serout b.2,n2400_16,(254,208,"")
case = %00010001: serout b.2,n2400_16,(254,208,"")
case = %00010010: serout b.2,n2400_16,(254,208,"")
case = %00010011: serout b.2,n2400_16,(254,208,"")
case = %00010100: serout b.2,n2400_16,(254,208,"")
case = %00010101: serout b.2,n2400_16,(254,208,"")
case = %00010110: serout b.2,n2400_16,(254,208,"")
case = %00010111: serout b.2,n2400_16,(254,208,"")
case = %00011000: serout b.2,n2400_16,(254,208,"")
endselect
return
Last edited: