This is my virgin post lol. Anyways I am fairly new to programming, and just curious if my following code is the only way/correct way to recieve user input while in a fullscreen enviroment. The code is the KeyboardInkey() help code modified. The original did not allow for CAPS. It works, just seems clunky.
Code: Select all
Procedure.s StringIn(X,Y)
AddText.s = ""
AdjText.s = ""
FinText.s = ""
CapFlag.b = 0
Repeat
ClearScreen(RGB(0,0,0))
ExamineKeyboard()
If (KeyboardPushed(#PB_Key_LeftShift) And CapFlag = 0) Or (KeyboardPushed(#PB_Key_RightShift) And CapFlag = 0)
AddText + KeyboardInkey()
AdjText = UCase(AddText)
FinText + AdjText
CapFlag = 1
AddText = ""
AdjText = ""
Else
FinText + KeyboardInkey()
EndIf
CapFlag = 0
If KeyboardReleased(#PB_Key_Back)
FinText = Left(FinText, Len(FinText)-1)
EndIf
If StartDrawing(ScreenOutput())
DrawingMode(1)
FrontColor(RGB(255,255,255))
DrawText(X, Y+40, "Enter some text, press enter to exit.")
DrawText(X, Y, FinText)
StopDrawing()
EndIf
If KeyboardReleased(#PB_Key_Return)
ProcedureReturn FinText
Break
EndIf
FlipBuffers()
ForEver
EndProcedure
InitSprite()
InitKeyboard()
OpenScreen(800,600,32,"Yah String Input!!")
MyString.s = StringIn(100,100)
ClearScreen(RGB(0,0,0))
StartDrawing(ScreenOutput())
DrawText(400,300,MyString)
StopDrawing()
FlipBuffers()
Delay(1000)
End
