[futurebasic] Re: [FB] Speed Help

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : May 2006 : Group Archive : Group : All Groups

From: David Cottrell <david.cottrell@...>
Date: Wed, 24 May 2006 00:12:03 +1000 (EST)
Dumb - forgot the length of the string...

Shows where my memory is at...

---- Original message ----
>Date: Tue, 23 May 2006 22:49:01 +1000 (EST)
>From: David Cottrell <david.cottrell@...>  
>Subject: Re: [FB] Speed Help  
>To: futurebasic@...
>
>Thanks Jay.
>
>This works as long as the files have the same delimiter between fields. 
Different 
>lengths no problem.
>
>My if statement to skip capitals does not work :(
>
>I also thought this would work to get a string for printing as a text file but also 
>no go.
>
>blockmove p+gMatches.offset1( r ),(@theText),gMatches.wordLen( r )
>
>I know I have done this before somewhere...
>
>Cheers
>
>david
>
>---- Original message ----
>>Date: Mon, 22 May 2006 17:57:50 -0500
>>From: Jay Reeve <jayreeve@...>  
>>Subject: Re: [FB] Speed Help  
>>To: futurebasic@...
>>
>>David,
>>
>>I got rid of a lot of redundancy. This is so short and sweet, I think  
>>it will be easy for you to follow. This replaces the one FN in the  
>>code I sent earlier.
>>
>>I notice this omits the check for uppercase. It will only match words  
>>with the same capitalization. Do you need the extra check?
>>
>>   e-e
>>   =J= a  y
>>    "
>>
>>
>>local
>>dim as ptr p1, p2, c1, c2, end1, end2
>>local fn matchFiles( file1H as long, file2H as long, delim )
>>' Jay Reeve, May 2006
>>'~'9
>>dim L
>>
>>p1 = [ file1H ] : p2 = [ file2H ]
>>end1 = p1 + fn gethandlesize( file1H ) - 2
>>end2 = p2 + fn gethandlesize( file2H ) - 2
>>
>>while ( p1 < end1 ) and ( p2 < end2 )
>>'We're at the beginning of a line in both files
>>c1 = p1 : c2 = p2 ' Start comparing chars here
>>
>>while c1.0`` == c2.0`` ' Check for match
>>long if c1.0`` == delim
>>' MATCH FOUND -- Make a record of it
>>gMatches.offset1( gMatchCount ) = p1 - [ file1H ]
>>gMatches.offset2( gMatchCount ) = p2 - [ file2H ]
>>gMatches.wordLen( gMatchCount ) = c1 - p1
>>gMatchCount ++
>>exit while
>>end if
>>c1 ++ : c2 ++
>>wend
>>
>>/* If a match was found, c1 & c2 both point to delims,
>>      so we'll get next line for both files.
>>    If no match, c1 & c2 point to the first char that's different.
>>      we'll get the next line for whichever points to the smaller  
>>char . */
>>if c2.0`` <= c1.0`` then p2 = fn nextLine( c2, end2 )
>>if c1.0`` <= c2.0`` then p1 = fn nextLine( c1, end1 )
>>wend
>>
>>end fn
>>
>>--
>>
>
>--
>