Input when using an Int
BlitzMax Forums/BlitzMax Beginners Area/Input when using an Int
| ||
hey guys..a very simple question but I just cant seem to figure it out.... I want to record a number from the user into an Int but using something like.... number : int = input("blah") gives me an error saying cannot convert from string to int.. would I have to actually convert it from a string? seems pretty long winded to me. |
| ||
its ok guys I figured it out. |
| ||
grr sorry, I thought I had sorted it when I checked out a forum post which said I should do.... guess = Int(Input("Input an integer: ")) but that just created an input in the output window instead of the app window I have setup a game window with Graphics,800,600,0,0 so I thought it would have put it to there any help guys? |
| ||
There is no graphical version of 'Input' in native BlitzMax. You can write your own using getchar() or check the code archives for other people's. Such as... BMax Input |
| ||
try thisGraphics 640,480,0 foo$ = gl_input$(10,10,"what is your name? ") SetColor 255,255,0 ; SetScale(2,2) DrawText "hello "+foo$+", how are you?",100,100 Flip WaitMouse End '------------------------------------- Function gl_input$(x,y,prompt$ = "?") Repeat Cls DrawText prompt$+m$,10,10 DrawText key,10,50 hit_key = 0 For key = 1 To 226 hit_key = KeyHit(key) If hit_key m$ = m$ + Chr(key) If key = KEY_ENTER Return m$ EndIf If key = KEY_BACKSPACE l = Len(m$) m = m[..l-2] EndIf EndIf Next Flip Until KeyHit(KEY_ESCAPE) End Function |