In [1]:
Sys_js.register_file ~name:"file" ~content:"line 1\nline 2"


Out[1]:
- : unit = ()

In [2]:
let f = open_in "file"
let a = input_line f
let b = input_line f
let c = input_line f
let () = close_in f


Out[2]:
val f : in_channel = <abstr>
Out[2]:
val a : string = "line 1"
Out[2]:
val b : string = "line 2"
Out[2]:
Exception: End_of_file.

In [6]:
Sys_js.register_file ~name:"file2" ~content:""


Out[6]:
- : unit = ()

In [7]:
let fout = open_out "file2"
let () = output_string fout "line 1\n"
let () = output_string fout "line 2\n"
(*let () = close_out fout*)


Out[7]:
val fout : out_channel = <abstr>

In [8]:
let fin = open_in "file2"
let a = input_line fin
let b = input_line fin
let c = input_line fin
let () = close_in fin


Out[8]:
Exception: Sys_error "file2: no such file or directory".

In [ ]: