shithub: mc

ref: 2ec6b23c4ef94a452996573cc79da96e05a96cc0
dir: /test/bio-delim.myr/

View raw version
use std
use bio

const main = {
	var f
	var d

	match bio.open("data/lines", bio.Rd)
	| `std.Some bio:	f = bio
	| `std.None:	std.fatal(1, "Unable to open data file\n")
	;;

	/* read first line */
	d = bio.readln(f)
	std.write(1, d)
	std.write(1, "\n")
	std.slfree(d)

	/* read second line, should not include \n */
	d = bio.readln(f)
	std.write(1, d)
	std.write(1, "\n")
	std.slfree(d)

	/* read to ';' */
	d = bio.readto(f, ";")
	std.write(1, d)
	std.write(1, "\n")
	std.slfree(d)

	/* read to ';'  again */
	d = bio.readto(f, ";")
	std.write(1, d)
	std.write(1, "\n")
	std.slfree(d)

	/* '--'  this time */
	d = bio.readto(f, "--")
	std.write(1, d)
	std.write(1, "\n")
	std.slfree(d)

	/* and without the terminator, we should get the remaining text */
	d = bio.readto(f, "not-there")
	std.write(1, d)
	std.write(1, "\n")
	std.slfree(d)
	
	bio.close(f)
}