My attempt at an input function for console apps..

BlitzMax Forums/BlitzMax Programming/My attempt at an input function for console apps..

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.

Oh, and here is the code that the original Input function calls.

'IN BRL.STANDARDIO LINE 56
Function Input$( prompt$=">" )
	StandardIOStream.WriteString prompt
	StandardIOStream.Flush
    Return StandardIOStream.ReadLine()
End Function

'IN BRL.STREAM LINE 380
Method ReadLine$()
		Local str$,buf:Byte[1024],p
		Repeat
			Local n:Byte
			If Read( Varptr n,1 )<>1 Exit
			If n=0 Exit
			If n=10 Exit
			If n=13 Continue
			buf[p]=n ; p:+1
			If p<>buf.length Continue
			str:+String.FromBytes(buf,p)
			p=0
		Forever
		If p str:+String.FromBytes(buf,p)
		Return str
	End Method