module copy1 import StdOverloaded import StdFile import ArgEnv import StdClass import StdArray import StdInt import StdString from StdMisc import abort processFile :: *File *File -> (*File, *File) processFile fin fout #! (end, fin) = fend fin | end = (fin, fout) #! (line, fin) = freadline fin #! fout = fwrites line fout | otherwise = processFile fin fout set_console_flag :: Int; set_console_flag = code { pushL _console_flag push_b_a 0 pop_b 1 push_node EMPTY 0 push_a_b 0 pop_a 1 } Start :: *World -> *World Start world | set_console_flag==0 = abort "cannot console" # args = getCommandLine | (size args) <> 2 = abort "use 1 argument" # (ok, fin, world) = fopen args.[1] FReadText world | not ok = abort ("cannot open" +++ args.[1]) # (fout, world) = stdio world # (fin, fout) = processFile fin fout # (ok, world) = fclose fin world | not ok = abort ("error closing " +++ args.[1]) | otherwise = world