Closed nuggreat closed 4 years ago
This is good. I had in mind an equivalent of "read_line" function found in the standard library of many languages. It would only get input from the user, accounting for the user moving cursor and deleting characters, print the characters as they are typed and return the string on enter key. It would also not limit the maximum number of characters in the string (that would make sense if kOS was more C - like rather than Python - like) or at least it would be a large number by default. The number only input could be separate function.
A single line input is more or less what you get with the string input. The maxlength is to make it easy for people to do nicer terminal layouts and not have to worry about overrun. The reason why I added a number only mode is because of some of my experience with with kOS GUIs and how bad the :TOSCALAR()
suffix is at converting to a number if there is any thing at all that throws off the parse it gives up on the conversion and ether crashes or goes with the default answer. It shouldn't be to hard to split them into different functions the only reason they the same is the commonalities between the two types of input for the actual concatenation steps.
The maxlength is to make it easy for people to do nicer terminal layouts
That is a good point, but it would be nice to make it an optional parameter with large default value for the string only version. It could be a mandatory parameter for the number only version where the max length also makes sense in regards to how big of a number the program is expecting.
I have refactored the main lib to spit the input into several functions, added a second simpler example, and got the first draft of the documentation done.
I tested it today, looks good.
This is a library for facilitating terminal input using direct key input as apposed to the on-screen keyboard form of
lib_input_string.ks
uses.The documentation is not done yet as I would like some feedback on the feature set I already have before I start work on the documentation for the lib it.