Example of input using entry$ by IanM29th Dec 2003 8:35
|
---|
Summary Simple example of entry$ Description Simple example of entry$, to allow input while the action still continues. The action in this case is simply a counter Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com sync rate 0 sync on do cls inc Counter NewMessage$ = InputUserMessage() if NewMessage$ <> "" then LastMessage$ = NewMessage$ text 0, 0, str$(Counter) text 0, 20, "Current Input : " + CurrentInput$ + "_" text 0, 40, "Last input : " + LastMessage$ sync loop global CurrentInput$ as string function InputUserMessage() local Result as string local Char as string local i as integer ` If anything is in the keyboard entry buffer we add the characters one by one to the current input string if entry$() <> "" for i = 1 to len( entry$() ) Char = mid$( entry$(), i ) ` If it's a backspace, remove the last character if Char = chr$( 8 ) if CurrentInput$ <> "" then CurrentInput$ = left$( CurrentInput$, len(CurrentInput$)-1 ) else ` If it's a valid character add it to the buffer if asc( Char ) >= 32 && asc( Char ) < 128 then CurrentInput$ = CurrentInput$ + Char ` If it's a return, pass on what we got and start again if asc( Char ) = 13 Result = CurrentInput$ CurrentInput$ = "" endif endif next i ` Clear out the buffer clear entry buffer endif endfunction Result |