' I am sure someone will know this answer and likely laugh a lot at my code, the variables are all declared and the long winded code works great but its very long code.
mainloop:
HSERIN [WAIT("**"),STR in_ctl\11\"!"]
if (in_ctl[0]) = "B" then goto SWB
goto mainloop
SWB:
PIN = in_ctl[1] ' 0 - 7
STATE = in_ctl[2] ' H or L
if PIN="0" and STATE = "H" then HIGH PortB.0
if PIN="0" and STATE = "L" then LOW PortB.0
if PIN="1" and STATE = "H" then HIGH PortB.1
if PIN="1" and STATE = "L" then LOW PortB.1
if PIN="2" and STATE = "H" then HIGH PortB.2
if PIN="2" and STATE = "L" then LOW PortB.2
'And so on
Goto mainloop
' Here's the question
' Using PBP pro 2.45 is there a neater way to do this with less code, I expected to be able to do something like the following to reduce 16 lines of code down to just 2:
SWB:
PIN = in_ctl[1] ' 0 - 7
STATE = in_ctl[2] ' H or L
if STATE = "H" then PortB.[PIN]=1
if STATE = "L" then PortB.[PIN]=0
Goto mainloop
Bookmarks