Home / Highlights / FAQ / Examples / Quick Start / Roadmap / Download / About Us
This is a simple example of using the read stream.
/tmp/numbers:
0
1
2
Source:
//Add "GetTimeNS() u64" to the end of _ExternC in standard
//Remove some asserts in standard to get a few ms improvement on the original file
printErr(string s) { write(2, s, s.size) }
main()
{
	array := decl u8[]
	r := OpenFile("/tmp/numbers")
	index := 0
	bufferTime := 0
	while !r.IsEOF()
	{
		bufferTime -= GetTimeNS()
		atEOL = r.BufferLine()
		bufferTime += GetTimeNS()
		if atEOL
			continue
		
		array.Push(r.Int() & 7 + '0')
		r.ExpectEOL()
		index++
	}
	if r.HasError {
		print("Invalid file?")
		return
	}
	print(array)
	ms = bufferTime/1000000
	printErr("BufferLine took $ms\n")
}