From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr 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 B7BF6BB84 for ; Mon, 10 Jul 2006 11:49:25 +0200 (CEST) Received: from furbychan.cocan.org (furbychan.cocan.org [80.68.91.176]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id k6A9nLkl005811 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Mon, 10 Jul 2006 11:49:25 +0200 Received: from rich by furbychan.cocan.org with local (Exim 3.35 #1 (Debian)) id 1FzsNv-00015c-00; Mon, 10 Jul 2006 10:48:59 +0100 Date: Mon, 10 Jul 2006 10:48:59 +0100 To: Jim Miller Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] in and out channels into memory Message-ID: <20060710094859.GA4083@furbychan.cocan.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.9i From: Richard Jones X-Miltered: at concorde with ID 44B222A1.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; ocaml:01 rec:01 netstring:01 lib:01 buffer:01 notepad:01 2006:98 wrote:01 caml-list:01 functions:01 defined:02 std:02 string:02 string:02 types:02 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 On Sun, Jul 09, 2006 at 09:53:29PM -0400, Jim Miller wrote: > Is there a way in OCaml to read and write into memory using in and out > channels in the standard distribution? It seems like there are functions > for converting everything else to in and out channels but I can't seem to > find anything for writing into and out of memory. If there isn't something > already, is there a function for creating new in and out channels? Not for the in/out_channel in the standard distribution. However if you can change the code to use the IO class types defined here (http://www.ocaml-programming.de/rec/IO-Classes.html) then you can use something like input_string from the Netstring library: let s = "1\n2\n3\n4" in let ch = new input_string s in ch#input_line () If you can't change the code, then the best you can do might be to read and write a temporary file (see: Filename.open_temp_file). Another alternative from the std lib is Buffer, but that also requires changing the code. Rich. -- Richard Jones, CTO Merjis Ltd. Merjis - web marketing and technology - http://merjis.com Team Notepad - intranets and extranets for business - http://team-notepad.com