How to display data from serin in a debug screen ?
ion
Posts: 101
According with the help file for serin, if we use the line
SERIN 1, 16780, [noparse][[/noparse]DEC sData]The program wait until it will get a non numeric value then store the data in the variable sData.What method to use to see in a debug screen what data you type, because until you press any non numeric key , the program just wait to the serin command and it will not advance to the Debug line ?Second question is related to the number of variable. Can we use a serin command like thisSERIN 1, 16780, [noparse][[/noparse]DEC4 sData, DEC4 pData]Ion
SERIN 1, 16780, [noparse][[/noparse]DEC sData]The program wait until it will get a non numeric value then store the data in the variable sData.What method to use to see in a debug screen what data you type, because until you press any non numeric key , the program just wait to the serin command and it will not advance to the Debug line ?Second question is related to the number of variable. Can we use a serin command like thisSERIN 1, 16780, [noparse][[/noparse]DEC4 sData, DEC4 pData]Ion
Comments
DEBUG sData···········' display ASCII character
DEBUG DEC sData······ ' display decimal value of sData
DEBUG HEX sData······ ' display hex value of sData
DEBUG BIN sData······ ' display binary value of sData
In you second example, you're using the DEC filter so only numeric characters ("0" - "9") will be accepted.· You are also limiting the number of characters per byte to four, so if your input string is:
"01234567"
then sData (which must be defined as a Word) will be 123, and pData (also a Word) will be 4567.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
What I want to do, ·is to see each character on the debug screen while I type.
As I said, for a
SERIN 1, 16780, [noparse][[/noparse]DEC4 sData]
I would like to see each character on the debug windows while I type them, and not the whole word after I completed the 4 digits to enter.
So in this case I would like to see :
1
12
123
1234
I do not want to use any ECHO to get them to the screen. I would like the DEBUG to display them
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
I taught so
Get_Value:
· value = 0
· digits = 0
Get_Char:
· DO
··· DEBUGIN char······················· ' get character
···· SELECT char······················· ' a number?
····· CASE "0" TO "9"
······· IF (digits < numDigits) THEN
········· DEBUG CRSRXY,
··············· col + digits, row, char ' display at row, col
········· value = value * 10··········· ' shift value digits left
········· value = value + (char - "0")· ' add new digit
········· digits = digits + 1·········· ' update digit count
······· ENDIF
····· CASE BKSP························ ' backspace?
······· IF (digits > 0) THEN
········· value = value / 10··········· ' correct value
········· digits = digits - 1·········· ' update digit count
········· DEBUG CRSRXY,
············· col + digits, row, " "··· ' clear last digit
······· ENDIF
····· CASE ELSE
······· IF (digits > 0) THEN EXIT······ ' terminate input?
··· ENDSELECT
· LOOP UNTIL (digits > numDigits)
· RETURN
I did in fact test this code (demo attached)·and it does what you want (with the flexibility to determine the number of digits to accept, as well as deal with a backspace character).· You must setup "row" and "col" for the display position before calling.· Note that the cursor positioning only works with the Stamp DEBUG screen, and is not applicable to external terminals like HyperTerm.· You must also have the "Echo Off" selection on the DEBUG screen checked.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
Post Edited (Jon Williams) : 9/28/2004 4:53:25 PM GMT
Did you ever taught about cloning yourself. A small group of Jon, will make miracles for Parallax and beat Microsoft
Thanks
Ion
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office