Microsoft Small Basic

Program Listing: GPD053-0
' cat 0.2 - list file
' Copyright © 2012-2016 Nonki Takahashi. The MIT License.
'
' History :
' 0.2 2016-03-24 Changed for Program object demo. (GPD053-0)
' 0.1 2012-07-14 Created. (GPD053)
'
CRLF = Text.GetCharacter(13) + Text.GetCharacter(10)
Not = "True=False;False=True;"
path = Program.GetArgument(1)
If path = "" Then
TextWindow.Write("Filename? ")
path = TextWindow.Read()
EndIf
' The following line could be harmful and has been automatically commented.
' buf = File.ReadContents(path) ' buffer
ReadLineFromBuf()
While Not[eof]
TextWindow.WriteLine(line)
ReadLineFromBuf()
EndWhile
Program.Delay(3000) ' wait 3 seconds
Program.End() ' end program

Sub ReadLineFromBuf
' param buf - buffer
' return line
' return eof - "True" if end of file
' return buf - updated buffer
ptr = Text.GetIndexOf(buf, CRLF) ' buffer pointer
If ptr = 0 Then
eof = "True"
Else
eof = "False"
line = Text.GetSubText(buf, 1, ptr - 1)
buf = Text.GetSubTextToEnd(buf, ptr + 2)
EndIf
EndSub