String bug, or am I missing something here?
BlitzMax Forums/BlitzMax Programming/String bug, or am I missing something here?
| ||
Right so... I'm not sure if this is a bug, or if I'm missing something here, but this seems very odd to me! Basically just write something and press enter, see if the message shows correctly. SuperStrict Local ChatStr:String Graphics(320, 240) While Not KeyDown(KEY_ESCAPE) Local InpChar:Byte = GetChar() Select InpChar Case KEY_RETURN Print("You Wrote: " + ChatStr) Notify("You Wrote: " + ChatStr) Default ChatStr:+Chr(InpChar) End Select DrawText(ChatStr, 0, 0) Flip(1) Cls() Wend Last edited 2012 |
| ||
You probably want to be putting the result of GetChar() into an Int, not a Byte. |
| ||
Sure sure, but put it into anything and the problem is still there. |
| ||
Well, i'm on an ipad right now so can't see what the problem actually is. |
| ||
you are adding chr(0), even key is not pressed. try this:SuperStrict Local ChatStr:String Graphics(320, 240) While Not KeyDown(KEY_ESCAPE) Local InpChar:Byte = GetChar() If inpchar Then Select InpChar Case KEY_RETURN Print("You Wrote: " + ChatStr) Notify("You Wrote: " + ChatStr) Default ChatStr:+Chr(InpChar) End Select EndIf DrawText(ChatStr, 0, 0) Flip(1) Cls() Wend Last edited 2012 |
| ||
Ah yes, that makes more sense. Thanks Zeke! |