Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Randy Bosma
  Where is Randy Bosma?
 
 Illinois - United States
 Randy Bosma
 To: Pete Sass
  Where is Pete Sass?
 Marathon, Ontario
 Canada
 Pete Sass
 Tags
Subject: RE: NEED FOR SPEED STRING PARSING
Thread ID: 416207 Message ID: 416309 # Views: 37 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: General VFP Topics
Date: Friday, December 26, 2014 4:03:13 PM         
   


> > Hi Pete.
> >
> >
> > That seems unreasonably slow. I'd add some logging using SECONDS() to see where your bottlenecks are.
> >
> > That being said, I agree with Ali that processing the file in 216 byte chunks may be faster. Also, CHRTRAN() can help with eliminating unwanted characters. For example:
> >
> >
* Create a string of illegal characters.
> > 
> > lcIllegal = ''
> > for lnI = 0 to 255
> > 	lcChar    = chr(lnI)
> > 	lcIllegal = lcIllegal + iif(isalpha(lcChar) or isdigit(lcChar), '', lcChar)
> > next lnI
> > 
> > * Create a variable for CR/LF.
> > 
> > lcCRLF = chr(13) + chr(10)
> > 
> > * Process the data in 216 byte chunks.
> > 
> > for lnI = 1 to ceiling(lnBitLength/216)
> > 	lnStart = (lnI - 1) * 216 + 1
> > 	lcData  = substr(lcDataString, lnStart, 216)
> > 	lcData  = chrtran(lcData, lcIllegal, '')
> > 	do while at('  ', lcData)
> > 		lcData = strtran(lcData, '  ', ' ')
> > 	enddo while at('  ', lcData)
> > 	lcData = lcData + lcCRLF
> > * Do something with lcData here, like write to a file
> > next lnI

> >
> > Merry Christmas!
> >
> > Doug
>
>
>
> Hi Doug,
>
> Thanks for the reply. I see what you are doing with the 216 strings but I do
> not understand what this is doing . . . or what you are trying to do?
>
do while at('  ', lcData)
>    lcData = strtran(lcData, '  ', ' ')
> enddo while at('  ', lcData)

>
>
> Can you advise as to what is suppose to happen within the Do While loop and what
> logical condition you are after here.
>
> Pete "the IceMan", from the Great White North of Canada.
> www.marathongriffincomputers.com

Pete,
quoting from the VFP help:
AT( ) searches the second character expression for the first occurrence of the first character expression. It then returns an integer indicating the position of the first character in the character expression found. If the character expression isn't found, AT( ) returns 0.
The search performed by AT( ) is case-sensitive. To perform a search that isn't case-sensitive, use ATC( ).


Doug undoubtedly meant to type:
do while at('  ', lcData) > 0 

His code removes instances of two spaces, and replaces them with one space, until there are no more instances of two spaces.

HTH,
Randy Bosma
-----------------
"Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so." ~ Douglas Adams

ENTIRE THREAD

NEED FOR SPEED STRING PARSING Posted by Pete Sass @ 12/23/2014 6:53:08 PM
RE: NEED FOR SPEED STRING PARSING Posted by Ali Koumaiha @ 12/23/2014 7:04:00 PM
RE: NEED FOR SPEED STRING PARSING Posted by Pete Sass @ 12/23/2014 9:18:02 PM
RE: NEED FOR SPEED STRING PARSING Posted by Greg Green @ 12/23/2014 9:32:14 PM
RE: NEED FOR SPEED STRING PARSING Posted by Pete Sass @ 12/23/2014 11:34:52 PM
RE: NEED FOR SPEED STRING PARSING Posted by Greg Green @ 12/24/2014 12:40:30 AM
RE: NEED FOR SPEED STRING PARSING Posted by Pete Sass @ 12/24/2014 1:59:48 AM
RE: NEED FOR SPEED STRING PARSING Posted by Greg Green @ 12/24/2014 4:06:32 AM
RE: NEED FOR SPEED STRING PARSING Posted by Jun Tangunan @ 12/24/2014 1:58:25 AM
RE: NEED FOR SPEED STRING PARSING Posted by Pete Sass @ 12/24/2014 2:48:33 AM
RE: NEED FOR SPEED STRING PARSING Posted by Jun Tangunan @ 12/24/2014 3:08:43 AM
RE: NEED FOR SPEED STRING PARSING Posted by Mike Yearwood @ 12/23/2014 10:26:18 PM
RE: NEED FOR SPEED STRING PARSING Posted by Pete Sass @ 12/24/2014 2:57:22 AM
RE: NEED FOR SPEED STRING PARSING Posted by Mike Yearwood @ 12/23/2014 10:35:06 PM
RE: NEED FOR SPEED STRING PARSING Posted by Pete Sass @ 12/24/2014 3:01:56 AM
RE: NEED FOR SPEED STRING PARSING Posted by Doug Hennig @ 12/23/2014 10:28:14 PM
RE: NEED FOR SPEED STRING PARSING Posted by Pete Sass @ 12/23/2014 11:10:55 PM
RE: NEED FOR SPEED STRING PARSING Posted by Randy Bosma @ 12/26/2014 4:03:13 PM
RE: NEED FOR SPEED STRING PARSING Posted by Chuanbing Chen @ 12/24/2014 12:16:21 AM
RE: NEED FOR SPEED STRING PARSING Posted by Pete Sass @ 12/24/2014 2:06:53 AM
RE: NEED FOR SPEED STRING PARSING Posted by Pete Sass @ 12/24/2014 5:49:20 AM
RE: NEED FOR SPEED STRING PARSING Posted by Mike Yearwood @ 12/29/2014 6:05:14 PM
RE: NEED FOR SPEED STRING PARSING Posted by Pete Sass @ 12/29/2014 7:30:28 PM
RE: NEED FOR SPEED STRING PARSING Posted by Zia Mughal @ 12/24/2014 8:23:15 AM
RE: NEED FOR SPEED STRING PARSING Posted by Pete Sass @ 12/24/2014 4:50:30 PM
RE: NEED FOR SPEED STRING PARSING Posted by Tony Vignone @ 12/24/2014 5:07:32 PM
RE: NEED FOR SPEED STRING PARSING Posted by Pete Sass @ 12/24/2014 5:53:57 PM
RE: NEED FOR SPEED STRING PARSING Posted by Tony Vignone @ 12/24/2014 9:21:34 PM
RE: NEED FOR SPEED STRING PARSING Posted by Tony Vignone @ 12/25/2014 8:31:14 AM
RE: NEED FOR SPEED STRING PARSING Posted by Pete Sass @ 12/25/2014 4:56:51 PM
RE: NEED FOR SPEED STRING PARSING Posted by Tony Vignone @ 12/25/2014 5:57:14 PM
RE: NEED FOR SPEED STRING PARSING Posted by Pete Sass @ 12/25/2014 9:01:03 PM
RE: NEED FOR SPEED STRING PARSING Posted by Tony Vignone @ 12/26/2014 2:51:27 PM
RE: NEED FOR SPEED STRING PARSING Posted by Pete Sass @ 12/26/2014 4:09:19 PM
RE: NEED FOR SPEED STRING PARSING Posted by Tony Vignone @ 12/26/2014 4:25:35 PM