[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2005-01-26 (15:37) |
From: | Yan Jun Daisy Chen <yjc01@d...> |
Subject: | extract info from file |
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