Yup, that's PicBasic Pro.
First thing to do is to change the keypad routines so that it only "gets the key's".
This will also reduce the program size quite a bit. Sending to the LCD and SEROUT can be done later, once you know what the character is.
There are other ways to do it, but I'm trying to keep it in the same context as your program.
For instance, with the alpha1: routine.
It can be reduced to ....Same for the alpha2 and main getkey routines.Code:alpha1: gosub getkey LOOKUP key,[" ABCDEFGHIJ"],Char RETURN
The idea is that the actual character you want will be stored in the "Char" (byte sized) variable. Then you can do what you want with it later, instead of 36 different versions of what to do with it if a certain key is pressed.
Then, once you have the kaypad routine only returning the desired characters, you can do something like this...Of course, this doesn't allow backspaces and the like while editing. But I gotta leave something for you to do.Code:Finished VAR BIT : Finished = 0 StrLen VAR BYTE : StrLen = 0 while not Finished gosub getkey if Char != EOM then ' End of message key htxt(StrLen) = Char LCDOUT Char StrLen = StrLen + 1 else ; originaly post as an endif (DOH!) Finished = 1 endif wend SEROUT2 PORTD.0, 813, [STR htxt\StrLen,13,10]
HTH,





Bookmarks