Oz and Mozart Users Mailing List

STDIN problem with Open.text (on Win32)


From: Aldo Calpini (dada@perl.it)
Date: Tue Mar 12 2002 - 15:23:19 CET


hello,

first of all some info:
  os: Windoze 2000
  oz: Mozart Compiler 1.2.3 (20011204) playing Oz 3
  me: clueless newbie ;-)

I have this code which is trying to read from STDIN:

functor
  import
    System(printInfo)
    Application(exit)
    Open(text file)
  define
    class TextFile
      from Open.file Open.text
    end
    proc {GetLines FILE}
      case {FILE getS($)} of false then
       {System.printInfo "file terminated, returning\n"}
      elseof LINE then
        {System.printInfo "got "}
        {System.printInfo LINE}
        {System.printInfo "\n"}
        {GetLines FILE}
      end
    end
  in
    local STDIN in
      STDIN = {New TextFile init(name:stdin)}
      {GetLines STDIN}
      {System.printInfo "done\n"}
    end
    {Application.exit 0}
  end

if I run this program as it is, I can see the "got" messages with the lines
I type in, but it doesn't stop when I press ^Z (EOF marker in Win32). I have
to press ^C to stop the program, at which point it dies with:
  *** Error handler entered ****
  *** Error handler exit ****

also, if I run the program with some input redirected (eg. getlines.exe
<testfile.txt), I see all the input lines, but again the program never stops
until ^C.

if I change init(name:stdin) with init(name:"testfile.txt"), everything goes
well. the program sees the EOF and correctly says "file terminated,
returning".

I have also tried testing {FILE atEnd($)}, but it seems this is always
false.

where is the problem? is this a bug in Win32 maybe?

cheers,
Aldo

__END__
$_=q,just perl,,s, , another ,,s,$, hacker,,print;
-
Please send submissions to users@mozart-oz.org
and administriva mail to users-request@mozart-oz.org.
The Mozart Oz web site is at http://www.mozart-oz.org/.



This archive was generated by hypermail 2b29.