caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Re: Text.get/Text.search in labltk
@ 2005-07-25  2:16 David Thomas
  0 siblings, 0 replies; 2+ messages in thread
From: David Thomas @ 2005-07-25  2:16 UTC (permalink / raw)
  To: caml-list

Ah, I found the problem.  `Atxy is looking for display
coordinates, rather than (line, char).  

--- David Thomas <david_hd@yahoo.com> wrote:

> Whoops. 
> 
> The l+1 was an earlier experiment that hadn't been
> removed.  It works the same whether it is there or
> not. 
> 
>  
> > The code:
> > let rec printwords () =
> >         match Text.search
> >                 ~switches:[`Regexp]
> >                 ~pattern:"[a-zA-Z]"
> >                 ~start:(`Atxy (0, 0), [`Wordend;
> > `Char
> > 1])
> >                 text
> >         with `Linechar (l, c) ->
> >                 Printf.printf "(%d, %d) -> %s\n%!"
> >                         l c
> >                         (Text.get
> >                                 ~start:(`Atxy
> (l+1,
> > c), [])
> >                                 ~stop:(`Atxy (l,
> c),
> > [`Lineend])
> >                                 text
> >                         );;
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam
> protection around 
> http://mail.yahoo.com 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


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

* Text.get/Text.search in labltk
@ 2005-07-24 18:37 David Thomas
  0 siblings, 0 replies; 2+ messages in thread
From: David Thomas @ 2005-07-24 18:37 UTC (permalink / raw)
  To: caml-list

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
                ~switches:[`Regexp]
                ~pattern:"[a-zA-Z]"
                ~start:(`Atxy (0, 0), [`Wordend; `Char
1])
                text
        with `Linechar (l, c) ->
                Printf.printf "(%d, %d) -> %s\n%!"
                        l c
                        (Text.get
                                ~start:(`Atxy (l+1,
c), [])
                                ~stop:(`Atxy (l, c),
[`Lineend])
                                text
                        );;







		
____________________________________________________
Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 
 


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

end of thread, other threads:[~2005-07-25  2:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-25  2:16 Text.get/Text.search in labltk David Thomas
  -- strict thread matches above, loose matches on Subject: below --
2005-07-24 18:37 David Thomas

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).