caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* extract info from file
@ 2005-01-26 15:37 Yan Jun Daisy Chen
  2005-01-26 19:14 ` [Caml-list] " Martin Jambon
  0 siblings, 1 reply; 2+ messages in thread
From: Yan Jun Daisy Chen @ 2005-01-26 15:37 UTC (permalink / raw)
  To: caml-list


I am trying to extract comments in a text file i.e. text between (* and
*).  I declared a globle sting variable, buff to store them, and want to
store all the comments extracted in a list of string. Is the sting
variable size fixed once I initialise it?

The code I came up with is:

open Unix;;

let fileReader = openfile "student.cd" [O_RDONLY] 0o640;;
let buff = ref "file: ";;
let fileSize = (fstat fileReader).st_size;;
(*let fileSize = 50;;*)
let noOfChar = ref 0;;

let extract_comment ()  =
  let openIndex = 0 in
  noOfChar := read fileReader !buff openIndex fileSize;
  (*print_string !buff;	print_newline();
  print_int !noOfChar;	print_newline();;*)


let main () =
  (*let fileContent = read fileReader !buff 0 5 in
  print_int fileContent;*)
  extract_comment();;

main ();;

Is there a simpler way to do this?

Thanks

Daisy


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-01-26 19:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-26 15:37 extract info from file Yan Jun Daisy Chen
2005-01-26 19:14 ` [Caml-list] " Martin Jambon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).