English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Text.get/Text.search in labltk
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-07-24 (18:37)
From: David Thomas <david_hd@y...>
Subject: Text.get/Text.search in labltk
I've run into an interesting issue.  There's a bug
somewhere, but I've no clue whether it's in my code or
the library.

The code below *should* (I think) print the second
word in the text box along with it's location. 
However, when I run it with "foo bar" in the text box,
I get "(1, 4) -> foo" and I can't figure out why.  If
I run it with "foo    bar" I get "(1, 7) -> foo" so it
definately seems to be finding the location of the
second word, but not getting it correctly.  I've been
fussing with it, and can't figure out what I'm doing
wrong, if anything.  Anyone have any notions?

The code:
let rec printwords () =
        match Text.search
                ~start:(`Atxy (0, 0), [`Wordend; `Char
        with `Linechar (l, c) ->
                Printf.printf "(%d, %d) -> %s\n%!"
                        l c
                                ~start:(`Atxy (l+1,
c), [])
                                ~stop:(`Atxy (l, c),

Start your day with Yahoo! - make it your home page