Just some minor modifications to your code
Code:
myvar var byte 'var output from keypress
Array var Byte [3] 'array variable to hold 3 keypresses
A0 var byte 'counter/index
B0 var Byte 'sum of digits
KeyPress Var Byte 'holds each keypress as it happens
Pause 2000 ' Wait for LCD to startup
A0=0 'index = 0
Ini:
lcdout $fe,1
lcdout "enter number"
B0 = 0 ' start with 0 in the sum of digits
@ READKEYPAD _myvar 'read keypress variable and place in myvar
b0 = b0*10+_myvar ' add in the new number
LOOKUP myvar,[0,"123A456B789C*0#D"],myvar 'use lookup table to diplay proper keypress
keypress = myvar 'pass the variable to solve strange character problem
' will contain the ascii character of the key pressed
lcdout keypress
pause 1000
lcdout $fe,1
'If keypress = "a" or "b" or "c" or "d" then goto numbers
if keypress = "*" then goto retry
If KeyPress = "#" then 'check input keypress for a # value
'if B0 > 255 then goto overflow 'test for overflow B0>255
HSEROUT ["here is the total ",dec B0,$0d,$0a] 'send result to pc com port
A0=0
ENDIF
If A0>2 then retry 'Ini
Array[A0]=KeyPress -48
A0=A0+1
goto ini
numbers: 'tell person to enter only numbers
lcdout "numbers only"
pause 1000
A0=0
myvar=0
goto ini
retry: 'is the * key is pressed then prompt for a retry and clear A0 and myvar
lcdout "retry"
pause 1000
lcdout $fe,1
A0=0
myvar=0
goto ini
overflow: 'tell person to enter 0 to 255 only
lcdout $fe,1
lcdout "0 to 255 ONLY!"
pause 1000
A0=0
myvar=0
goto ini
Bookmarks