How to take input

BlitzPlus Forums/BlitzPlus Programming/How to take input

nyybaseball(Posted 2014) [#1]
How do I take a number input in a blitz gui window program?


Matty(Posted 2014) [#2]
You will have to check for events such as changes when the text is input on each keystroke then validate the value entered. If it is a non numeric value discard it.


RemiD(Posted 2014) [#3]
Easy way : with Input()

More complex way : with keyhit() or keydown() and your own routine to detect which keys have been pressed and store the result as a string.
Then you can use Int(XString$) to convert a string into an integer or Float(XString$) to convert a string into a float and then do what you want with it...


Matty(Posted 2014) [#4]
Generally keyhit etc doesn't work very well with gui controls in blitzplus....I'm happy to be corrected on this but processing is slightly different because it uses events.


Midimaster(Posted 2014) [#5]
With PeekEvent()...

http://www.blitzbasic.co.nz/bpdocs/command.php?name=PeekEvent&ref=comments

...you can check whether there is an event. PeekEvent() will return an ID. If this ID is $103 it is an keyboard stroke and EventData()...

http://www.blitzbasic.co.nz/bpdocs/command.php?name=EventData&ref=comments

.... will contain the ASCII code. Now you can react as you want.

With EventSource() you can check whether the source of this event is really your gadget