Input function

BlitzPlus Forums/BlitzPlus Programming/Input function

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Thanks Peer, maybe exist an better solution, but in my case the following code seems to work...

Function GUI_EditText (PosX, PosY, Message$, MinLength, MaxLength, Value$, hImage)

Elapsedtime = MilliSecs()

GUI_Display_text (PosX,PosY, Message$ + Value$)

While Not KeyDown (28) And Len(Value$) >= MinLength
	
	Flip

	If (MilliSecs() > Elapsedtime + 50) Then

		Elapsedtime = MilliSecs()

		If KeyDown(14) Then

			If Len(Value$) > 0 Then 
				Value$ = Left$(Value$, Len(Value$) -1)
			End If
		
		Else

			KeyValue = GetKey()
			Char$ = Chr$(KeyValue)
			If Len(Value$) < MaxLength Then
				If (KeyValue => 48 And KeyValue <=57) Or (KeyValue => 65 And KeyValue <= 90) 
				Or (KeyValue => 97 And KeyValue <= 122) Then
					Value$ = Value$ + Lower(Char$)

				Else
;					If Not ( KeyDown (14) Or KeyDown(28)) Then play a sound
				End If
			End If
		End If
		
	End If
		
		If Len(Value$) <= (MinLength-1) And KeyDown (28) Then
			; play a sound !!!
		End If

	DrawImage hImage, 0, 0

	GUI_Display_text (PosX, PosY, Message$ + Value$ + "|")
	
Wend
	
End Function