Shop OBEX P1 Docs P2 Docs Learn Events
PropWare's input_prompt method: thoughts? — Parallax Forums

PropWare's input_prompt method: thoughts?

DavidZemonDavidZemon Posts: 2,973
edited 2014-12-14 20:21 in Propeller 1
I've just written a new method in PropWare. I'm curious to hear the opinions of others on the structure.

Example usage can be found here:
https://github.com/DavidZemon/PropWare/blob/release-2.0-nightly/Examples/PropWare_Scanner/Scanner_Demo.cpp

Scanner is here
https://github.com/DavidZemon/PropWare/blob/release-2.0-nightly/PropWare/scanner.h

and Comparator is here
https://github.com/DavidZemon/PropWare/blob/release-2.0-nightly/PropWare/PropWare.h#L211

A common task when reading from serial is to ask a human for an input variable. Since humans are notoriously unreliable, you might want some error checking. My goal is to provide a (relatively) simple and flexible way for a programmer to get reliable data from the end user. This requires a multi-step process:
1) Prompt the user (could be an empty string if the programmer so desired)
2) Read the input
3) check if input is valid
3 == false) print error and loop
3 == true) return

So what are your thoughts on the code? Can you think of any way to make it simpler?

Thanks,
David
Sign In or Register to comment.