From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA01862; Thu, 26 Apr 2001 19:19:32 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA01893 for ; Thu, 26 Apr 2001 19:19:31 +0200 (MET DST) Received: from mail.mangoosta.net (mail1.mangoosta.net [217.11.161.5]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f3QHJU506674 for ; Thu, 26 Apr 2001 19:19:30 +0200 (MET DST) Received: from adsl165-94.mangoosta.net ([217.11.165.94] helo=alan-schm1p) by mail.mangoosta.net id 14spLY-0006rT-00; Thu, 26 Apr 2001 12:14:28 -0500 Received: by alan-schm1p (sSMTP sendmail emulation); Thu, 26 Apr 2001 19:10:46 +0200 From: Alan Schmitt Date: Thu, 26 Apr 2001 19:10:46 +0200 To: Mark Scheffer Cc: caml-list@inria.fr Subject: Re: [Caml-list] copy file Message-ID: <20010426191046.K7658@alan-schm1p.inria.fr> Mail-Followup-To: Mark Scheffer , caml-list@inria.fr References: <007001c0ce71$8cbbd440$984dbbd4@zaxsystem> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2i In-Reply-To: <007001c0ce71$8cbbd440$984dbbd4@zaxsystem>; from zax@chello.nl on Thu, Apr 26, 2001 at 06:54:24PM +0200 Organization: INRIA Rocquencourt Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi, Correctly indenting the second function, you get: let cp f1 f2 = (* Opening channels, f1 firsty, then f2 *) let inch = try open_in f1 with Sys_error msg -> prerr_endline (f1^": "^msg); raise (Failure "cp") | _ -> prerr_endline ("Unknown exception while opening "^f1); raise (Failure "cp") in let outch = try open_out f2 with Sys_error msg -> close_in inch; prerr_endline (f2^": "^msg); raise (Failure "cp") | _ -> close_in inch; prerr_endline ("Unknown exception while opening "^f2); raise (Failure "cp") in (* Copying and then closing *) try copy inch outch with End_of_file -> close_in inch; close_out outch (* close_out flushes *) | exc -> close_in inch; close_out outch; raise exc ;; So basically you just define a function here ... If you never call it, nothing happens. Alan >Hello Caml users, > >I'm new to caml and have compiled this cp.ml file on my windows system using >"ocamlc -o cp.exe cp.ml". >However, I do not get any response when trying to use it. Is there an error >in the file? > >Thanks in advance for any help that might get this to work. > > >- Mark. > >--- > >(* File copier.ml *) > >let copy inch outch = > (* inch and outch are supposed to be opened channels *) > try (* actual copying *) > while true > do output_char outch (input_char inch) > done > with End_of_file -> (* Normal termination *) > raise End_of_file > | Sys_error msg -> (* Abnormal termination *) > prerr_endline msg; > raise (Failure "cp") > | _ -> (* Unknown exception, maybe interruption? *) > prerr_endline "Unknown error while copying"; > raise (Failure "cp") >;; > > >let cp f1 f2 = > (* Opening channels, f1 firsty, then f2 *) > let inch = > try open_in f1 > with Sys_error msg -> > prerr_endline (f1^": "^msg); > raise (Failure "cp") > | _ -> prerr_endline ("Unknown exception while opening "^f1); > raise (Failure "cp") >in >let outch = > try open_out f2 > with Sys_error msg -> > close_in inch; > prerr_endline (f2^": "^msg); > raise (Failure "cp") > | _ -> close_in inch; > prerr_endline ("Unknown exception while opening "^f2); > raise (Failure "cp") >in (* Copying and then closing *) > try copy inch outch > with End_of_file -> close_in inch; close_out outch > (* close_out flushes *) > | exc -> close_in inch; close_out outch; raise exc > >;; > > >------------------- >To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr -- The hacker: someone who figured things out and made something cool happen. ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr