I don't use any memory pointer operations in the whole thing! How can it give an invalid memory access?
Edit: MUCH shorted trigger code. Instructions: Run, press enter at the prompt.
Note: The code does NOT work, but the invalid memory access error is triggered BEFORE the error in my code! (Which is not an invalid memory access, but an infinite recursion loop.)
Code: Select all
OpenConsole()
Global Look.s
Global Stream.s
;Read a character into Look
Procedure GetChar()
Look = Left(Stream,1)
Stream = Right(Stream, Len(Stream)-1)
EndProcedure
;Recognize whitespace
Procedure.b IsWhiteSpace(s.s)
Select s.s
Case " "
Case #TAB$
Default
ProcedureReturn 0
EndSelect
ProcedureReturn 1
EndProcedure
;Recognize a newline
Procedure IsNewline(s.s)
ProcedureReturn ((s.s = #CR$) Or (s.s = #LF$))
EndProcedure
;Skip whitespace
Procedure EatWhite()
While IsWhiteSpace(Look)
GetChar()
Wend
EndProcedure
;Skip newlines
Procedure EatLines()
While IsNewline(Look)
GetChar()
Wend
EndProcedure
;Skip whitespace and newlines
Procedure EatBlank()
While IsWhiteSpace(Look) Or IsNewline(Look)
EatWhite()
EatBlank() ;Removing this fixed it. (It goes into an infinite loop of course unless you replace with EatLines())
Wend
EndProcedure
Stream = Input()+#CR$ : PrintN("")
GetChar()
EatBlank()
Input()