"#iota.isbpl" include native stream def STREAM.create.file.in riota =STREAM.create.file.in def STREAM.create.file.out iota =STREAM.create.file.out def STREAM.create.socket iota =STREAM.create.socket def STREAM.close iota =STREAM.close def STREAM.read iota =STREAM.read def STREAM.write iota =STREAM.write "not implemented:" # def STREAM.aread iota =STREAM.aread def STREAM.awrite iota =STREAM.awrite def STREAM.create.server iota =STREAM.create.server func STREAM.stdin { getos strlowercase "win" astartswith dup if { "conIN$" 2 stop } not if { "/dev/stdin" 2 stop } } func stream.readline { def id =id def byte 0 =byte def array 0 anew =array def i 1 neg =i [ id STREAM.read stream dup =byte _char byte -1 eq if { ] pop -1 2 stop } while { ( i 1 + =i ) ( byte 10 eq not byte -1 eq not and ) } { id STREAM.read stream dup =byte _char } pop ] =array array alen 0 eq if { array _string 2 stop } array array alen 1 - aget _int 13 eq if { def arr array alen 1 - anew =arr array arr 0 0 arr alen acopy =array } array _string } func stream.write { def id =id def str _array =str def i 1 neg =i while { ( i 1 + =i ) ( i str alen lt ) } { str i aget id STREAM.write stream } }