-
On what lines does a string occur?
I'm trying to determine all the lines where a string occurs in a memo field
or other string and I'm coming up blank. I could loop through all the lines
to determine this, but is there a simple function call that lets me search
by occurrence instead? The reason I need the line number is that I want to
manipulate the entire line, not just the string I'm searching for.
Of course, AtLine() tells you the first occurrence, but how about the rest
of them?
--
William Fields
MCP - Microsoft Visual FoxPro
US Bankruptcy Court
Phoenix, AZ
-
Re: On what lines does a string occur?
hard to say. Will this do?
lcSearchString='...'
FOR i = 1 TO OCCURS(lcSearchString,MText)
? MLINE(MTEXT,ATC(lcSearchString, MText, i) )
NEXT
"William Fields" <Bill_Fields@azb.uscourts.gov> wrote in message
news:39176294@news.devx.com...
> I'm trying to determine all the lines where a string occurs in a memo
field
> or other string and I'm coming up blank. I could loop through all the
lines
> to determine this, but is there a simple function call that lets me search
> by occurrence instead? The reason I need the line number is that I want to
> manipulate the entire line, not just the string I'm searching for.
>
> Of course, AtLine() tells you the first occurrence, but how about the rest
> of them?
>
> --
> William Fields
> MCP - Microsoft Visual FoxPro
> US Bankruptcy Court
> Phoenix, AZ
>
>
>
>
-
Re: On what lines does a string occur?
Hi again
Here's a more useful answewr to this problem I hope.
What a line in a memo, editbox or string? If you want to the lines you see
in an editbox you have to find a MemoWidth setting such that each MLINE()
exactly matches the rows you see. Given that and given that the lines where
your searchvalue is found are different from other rows containing the
searchstring you could get the row numbers in a loop. Suppose we're looking
for occurances of "123" in eb.value
for i = 1 to memlines(eb.value)
if '123' $ mline(eb.value,i)
* debugout mline(eb.value,i)
debugout atcline(mline(eb.value,i),eb.value)
endif
next
I hope there are better ways. With word-wrapped text it's very tricky.
Getting the offsets for the searchstring is supported by AT()
FOR i = 1 TO OCCURS('123',eb.text)
? ATC('123', eb.text, i)
NEXT
-Anders
"William Fields" <Bill_Fields@azb.uscourts.gov> wrote in message
news:39176294@news.devx.com...
> I'm trying to determine all the lines where a string occurs in a memo
field
> or other string and I'm coming up blank. I could loop through all the
lines
> to determine this, but is there a simple function call that lets me search
> by occurrence instead? The reason I need the line number is that I want to
> manipulate the entire line, not just the string I'm searching for.
>
> Of course, AtLine() tells you the first occurrence, but how about the rest
> of them?
>
> --
> William Fields
> MCP - Microsoft Visual FoxPro
> US Bankruptcy Court
> Phoenix, AZ
>
>
>
>
-
Re: On what lines does a string occur?
Thanks a lot Anders. In particular, I'm interested in actual memo fields or
string variables. This should get me where I need to go.
--
William Fields
MCP - Microsoft Visual FoxPro
US Bankruptcy Court
Phoenix, AZ
"Anders Altberg" <anders.altberg@swipnet.se> wrote in message
news:3917e104$1@news.devx.com...
> Hi again
> Here's a more useful answewr to this problem I hope.
> What a line in a memo, editbox or string? If you want to the lines you see
> in an editbox you have to find a MemoWidth setting such that each MLINE()
> exactly matches the rows you see. Given that and given that the lines
where
> your searchvalue is found are different from other rows containing the
> searchstring you could get the row numbers in a loop. Suppose we're
looking
> for occurances of "123" in eb.value
> for i = 1 to memlines(eb.value)
> if '123' $ mline(eb.value,i)
> * debugout mline(eb.value,i)
> debugout atcline(mline(eb.value,i),eb.value)
> endif
> next
> I hope there are better ways. With word-wrapped text it's very tricky.
> Getting the offsets for the searchstring is supported by AT()
> FOR i = 1 TO OCCURS('123',eb.text)
> ? ATC('123', eb.text, i)
> NEXT
>
> -Anders
>
> "William Fields" <Bill_Fields@azb.uscourts.gov> wrote in message
> news:39176294@news.devx.com...
> > I'm trying to determine all the lines where a string occurs in a memo
> field
> > or other string and I'm coming up blank. I could loop through all the
> lines
> > to determine this, but is there a simple function call that lets me
search
> > by occurrence instead? The reason I need the line number is that I want
to
> > manipulate the entire line, not just the string I'm searching for.
> >
> > Of course, AtLine() tells you the first occurrence, but how about the
rest
> > of them?
> >
> > --
> > William Fields
> > MCP - Microsoft Visual FoxPro
> > US Bankruptcy Court
> > Phoenix, AZ
> >
> >
> >
> >
>
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks