Version française
Home     About     Download     Resources     Contact us    
Browse thread
open_file
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Oliver Bandel <oliver@f...>
Subject: Re: [Caml-list] read file
On Wed, Jan 26, 2005 at 02:41:41PM +0000, Yan Jun Daisy Chen wrote:
>  I am trying to extract all the
> comments i.e. all the text between (* and *) in a text file and store
> them in a list of string. How do u determin the length of the file?

The length of the file?
Not necessary to know.
Or are the comments maybe as long as the file itself?

You better do using OCaml's built-in operations for reading files.

Look for open_in, read_line and so forth.

You also can use the Buffer-module to be much faster,
when appending strings together to a bigger string.

You can do such scanning with ocamllex. But it's also possible
to write your own scanner.

Do not use Unix-module for that stuff. It's portable to use the built-in
functions open_in and such stuff (like read_line and so forts), or the
Buffer-module.

Use Unix-module only, if you need it (e.g. reading from pipes or such stuff).


Ciao,
   Oliver