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 19993BC8C for ; Tue, 25 Jan 2005 23:19:33 +0100 (CET) Received: from finch.doc.ic.ac.uk (finch.doc.ic.ac.uk [146.169.1.194]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j0PMJWux022727 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 25 Jan 2005 23:19:32 +0100 Received: from linnet.doc.ic.ac.uk ([146.169.1.10]) by finch.doc.ic.ac.uk with esmtps (TLSv1:AES256-SHA:256) (Exim 4.43) id 1CtZ22-0008Is-F3 for caml-list@yquem.inria.fr; Tue, 25 Jan 2005 22:19:30 +0000 Received: from hordewebuser by linnet.doc.ic.ac.uk with local (Exim 4.20) id 1CtZ22-0003Yg-Bp for caml-list@yquem.inria.fr; Tue, 25 Jan 2005 22:19:30 +0000 Received: from host81-129-38-167.range81-129.btcentralplus.com (host81-129-38-167.range81-129.btcentralplus.com [81.129.38.167]) by www.doc.ic.ac.uk (IMP) with HTTP for ; Tue, 25 Jan 2005 22:19:30 +0000 Message-ID: <1106691570.41f6c5f250fdc@www.doc.ic.ac.uk> Date: Tue, 25 Jan 2005 22:19:30 +0000 From: yjc01@doc.ic.ac.uk To: caml-list@yquem.inria.fr Subject: open_file MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.2 X-Originating-IP: 81.129.38.167 Sender: hordewebuser X-Miltered: at concorde with ID 41F6C5F4.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; compilation:01 daisy:98 unix:01 unix:01 functions:01 int:01 string:03 string:03 module:03 let:03 let:03 variable:06 wrong:08 file:08 file:08 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.7 required=5.0 tests=FROM_ENDS_IN_NUMS, NO_REAL_NAME autolearn=disabled version=3.0.0 X-Spam-Level: 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. The code I came up with is as follows: open Unix;; let file_reader = openfile "sudent.cd" [O_RDONLY] 0o640;; let buff = ref "empty";; let main () = let file_content = read file_reader !buff 1 5 in print_int file_content; print_string !buff;; main (); I couldn't work out what went wrong. Can anyone help?!! Daisy