From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 955C0BC8C for ; Tue, 25 Jan 2005 23:58:54 +0100 (CET) Received: from first.in-berlin.de (dialin-145-254-053-076.arcor-ip.net [145.254.53.76]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j0PMwrew027103 for ; Tue, 25 Jan 2005 23:58:53 +0100 Received: by first.in-berlin.de (Postfix, from userid 501) id EFBE7A39B6; Tue, 25 Jan 2005 23:58:53 +0100 (CET) Date: Tue, 25 Jan 2005 23:58:53 +0100 From: Oliver Bandel To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] open_file Message-ID: <20050125225853.GC667@first.in-berlin.de> References: <1106691570.41f6c5f250fdc@www.doc.ic.ac.uk> <41F6CB7B.7050406@1969.ws> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <41F6CB7B.7050406@1969.ws> User-Agent: Mutt/1.5.6i X-Miltered: at concorde with ID 41F6CF2D.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; oliver:01 bandel:01 oliver:01 in-berlin:01 caml-list:01 wrote:01 wrote:01 compilation:01 ocamlc:01 ocamlopt:01 cmxa:01 compilation:01 overkill:01 pervasives:01 ocaml:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.0 X-Spam-Level: On Tue, Jan 25, 2005 at 02:43:07PM -0800, Karl Zilles wrote: > (forgot to copy the list, originally) > > yjc01@doc.ic.ac.uk wrote: > > > I tried to read in a text file and extract the string between (* and > *) into a variable, buff, by using the openfile and read functions in > Unix module. But get an error on compilation. > > > My guess is that you aren't including the unix library on your compile > command line: > > ocamlc [other_options] unix.cma [other_files] > ocamlopt [other_options] unix.cmxa [other_files] > OH,awell, the error was during compilation? Well, I have overlooked this. It's *always* good to have more informations on the kind of errors. When the compilation-errors are gone, I'm sure there will be many errors possivle during execution.... [...] > > print_int file_content; > > print_string !buff;; > > main (); > > I couldn't work out what went wrong. Can anyone help?!! It couldn't work, because there is only one ";" at the last line... > > Also, using the Unix libray is probably overkill for this kind of thing. Seems so. > You might want to switch to the Pervasives library, which is > automatically included with all ocaml programs. Yes - that's a good high-level handling of I/O. It's buffered and a quite good thing! :) Ciao, Oliver