Help with using Keyboard Object
Guys,
keyboard's getkey method returns one char at a time.
I need to type in 123 capturing the chars and convert them to a numeric 123.
In the other high level languages I've used you would type 123 then use a string to numeric method to get the result you want. I am stumped as to how to proceed. I've tried many hours to get the results I want.
Someone must have solved this problem using the Propeller?
I would appreciate any help you can give to me in this matter.
Thanks
keyboard's getkey method returns one char at a time.
I need to type in 123 capturing the chars and convert them to a numeric 123.
In the other high level languages I've used you would type 123 then use a string to numeric method to get the result you want. I am stumped as to how to proceed. I've tried many hours to get the results I want.
Someone must have solved this problem using the Propeller?
I would appreciate any help you can give to me in this matter.
Thanks

Comments
http://obex.parallax.com/objects/23/
I do thank you for taking the time to respond!
Here is my problem: I have tried to use Numbers. In other programs I have used, Nums.FromStr and Nums.ToStr ect., but this does not help me. and Mike If I were as great at programing the Propeller as you are we would not be having this discussion! I took a look at FullDuplexSerialPlus. If I could adapt any of that I would most likely be in your company! Well, from what I wrote above I am not in your company! So, I need some basic help if possible?
It would have helped if I had mentioned that I am using TV_Text and have created a menu system that gets its input from a keyboard. All is well until I need to type a number to pass to a variable. If all I needed to pass was a char I know how to handle that!
I hope that you fellows will give this another look.
Thanks
num := 0 repeat char := kb.getkey if char => "0" and char =< "9" num := num * 10 + char - "0" 'tv.out(char) until char == 13It expects a <return> to terminate the number input.Every number is echoed with TV_Text if uncomment the tv.out(char).
Andy
Thank you very much!! This is elegant in its simplicity.
I will try this tomorrow and post the results.
I would be interested in any other solutions, just for the sake of having others for learning purposes.
Thanks to all
PUB decimalToInteger(characters) | sign '' 10 Stack Longs '' //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// '' // Converts a decimal string into an integer number. Expects a string with only "+-0123456789" characters. '' // '' // If the string has a "-" sign as its leading character the converted integer returned will be negated. '' // '' // If the string has a "+" sign as its leading character the converted integer returned will not be negated. '' // '' // Returns the converted integer. By default the number returned is positive and the "+" sign is unnecessary. '' // '' // Characters - A pointer to the decimal string to convert. The number returned will be 2's complement compatible. '' //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// characters := checkSign(ignoreSpace(characters), @sign) repeat (strsize(characters) <# 10) ifnot(checkDigit(characters, "0", "9")) quit result := ((result * 10) + (byte[characters++] & $F)) result *= signIf you want the whole object, it is inside the zip file on this thread http://forums.parallax.com/showthread.php?132901-Where-is-KyeDOS-latest-vesion post #6, called ASCIIO_STREngine
Thank you for the direction. I have downloaded both and will study them.
I admire Kye's work, but for a "newbie" he's way beyond. I realize that he is not creating objects for "newbies" but as we progress hopefully we will understand. I have kept all his work that I can find in hopes of using his objects in the future.
I started programming in 1972 and processed from there. I am good with high level programing languages. This is my first with the nuts and bolts approach.
Once, again thank you to all!
Ariba (Andy) your algorithm was the perfect fit for me and is now part of my menu application! THANKS!!
Stan