Re: v13 (+?) - Replace String [warning]
> On Jun 29, 2017, at 3:33 PM, Chip Scheide via 4D_Tech <4d_tech@lists.4d.com> > wrote: > > I have a question.. what does RVLB (at the end of the blob) do? It is at the start of the blob and identifies the byte order. If it was a blob from an old PPC Mac, it would be BLVR. Next byte is the type (as returned by 4D Type command) followed by 4 bytes for the length. Then the data. You can see these details by looking at the blob after executing VARIABLE TO BLOB. John DeSoi, Ph.D. ** 4D Internet Users Group (4D iNUG) FAQ: http://lists.4d.com/faqnug.html Archive: http://lists.4d.com/archives.html Options: http://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
Re: v13 (+?) - Replace String [warning]
Chip: AFAIK, that's the marker that 4D added "way back when" when 4D started to support BLOB's. It's used to differentiate between a picture and a BLOB. -- Douglas von Roeder 949-336-2902 On Thu, Jun 29, 2017 at 1:33 PM, Chip Scheide via 4D_Tech < 4d_tech@lists.4d.com> wrote: > I have a question.. what does RVLB (at the end of the blob) do? > > > On Wed, 28 Jun 2017 06:09:43 +0800, Alan Chan via 4D_Tech wrote: > > Hi Chip, > > > > Try the following and it should be done in a second or 2 (compiled). > > > > //ES_ReplaceStr_Shrink($source;$oldString;$newString;{$count > > pointer})->Resulted text > > C_TEXT($0;$1;$2;$3;$source;$oldStr;$newStr;$result;$tempTxt) > > C_POINTER($4) > > > C_LONGINT($oldLen;$newLen;$oldStrLen;$NewStrLen;$count;$ > offset;$offset2;$start;$pos) > > C_BLOB($blob;$blob2) > > $source:=$1 > > $oldLen:=Length($source) //$source is the source text > > $oldStr:=$2 > > $newStr:=$3 > > $oldStrLen:=Length($oldStr) > > $newstrlen:=Length($newStr) > > > > SET BLOB SIZE($blob;$oldlen*2+9;0) > > $offset:=9 > > $start:=1 > > $count:=0 > > Repeat > > $pos:=Position($oldstr;$source;$start;*) > > If ($pos>0) > > $tempTxt:=Substring($source;$start;$pos-$start)+$newStr > > $start:=$pos+$oldStrLen > > If (Length($tempTxt)>0) > > $offset2:=0 > > VARIABLE TO BLOB($tempTxt;$blob2;$offset2) > > COPY BLOB($blob2;$blob;9;$offset;$offset2-9) > > $offset:=$offset+$offset2-9 > > End if > > $count:=$count+1 > > End if > > Until ($pos=0) > > > > If ($count>0) > > If ($start<=$oldlen) > > $tempTxt:=Substring($source;$start) > > If (Length($tempTxt)>0) > > $offset2:=0 > > VARIABLE TO BLOB($tempTxt;$blob2;$offset2) > > COPY BLOB($blob2;$blob;9;$offset;$offset2-9) > > End if > > End if > > If ($oldStrlen>$NewStrLen) > > $newLen:=$oldLen+(($NewStrLen-$oldStrLen)*$count) > > SET BLOB SIZE($blob;$newlen*2+9) > > Else > > $newlen:=$oldLen > > End if > > > > $blob{0x}:=Character code("R") > > $blob{0x0001}:=Character code("V") > > $blob{0x0002}:=Character code("L") > > $blob{0x0003}:=Character code("B") > > $blob{0x0004}:=0x0021 > > $blob{0x0005}:=$newlen%256 > > $blob{0x0006}:=($newlen\256)%256 > > $blob{0x0007}:=($newlen\65536)%256 > > $blob{0x0008}:=($newlen\16777216) > > $offset:=0 > > BLOB TO VARIABLE($blob;$result;$offset) > > $0:=$result > > > > Else > > $0:=$1 > > End if > > > > If (Count parameters>3) > > $4->:=$count > > End if > > > > Alan Chan > > > > 4D iNug Technical <4d_tech@lists.4d.com> writes: > >> $Source:=Replace String($Source;Char(9);"";*) > >> > >> Doesn't look so bad, does it? > >> Turns out there are over 550,000 tabs in the text. > >> Replace String, did indeed (eventually) return, but it took about 30 > >> minutes. > > > > ** > > 4D Internet Users Group (4D iNUG) > > FAQ: http://lists.4d.com/faqnug.html > > Archive: http://lists.4d.com/archives.html > > Options: http://lists.4d.com/mailman/options/4d_tech > > Unsub: mailto:4d_tech-unsubscr...@lists.4d.com > > ** > --- > Gas is for washing parts > Alcohol is for drinkin' > Nitromethane is for racing > ** > 4D Internet Users Group (4D iNUG) > FAQ: http://lists.4d.com/faqnug.html > Archive: http://lists.4d.com/archives.html > Options: http://lists.4d.com/mailman/options/4d_tech > Unsub: mailto:4d_tech-unsubscr...@lists.4d.com > ** > ** 4D Internet Users Group (4D iNUG) FAQ: http://lists.4d.com/faqnug.html Archive: http://lists.4d.com/archives.html Options: http://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
Re: v13 (+?) - Replace String [warning]
I have a question.. what does RVLB (at the end of the blob) do? On Wed, 28 Jun 2017 06:09:43 +0800, Alan Chan via 4D_Tech wrote: > Hi Chip, > > Try the following and it should be done in a second or 2 (compiled). > > //ES_ReplaceStr_Shrink($source;$oldString;$newString;{$count > pointer})->Resulted text > C_TEXT($0;$1;$2;$3;$source;$oldStr;$newStr;$result;$tempTxt) > C_POINTER($4) > C_LONGINT($oldLen;$newLen;$oldStrLen;$NewStrLen;$count;$offset;$offset2;$start;$pos) > C_BLOB($blob;$blob2) > $source:=$1 > $oldLen:=Length($source) //$source is the source text > $oldStr:=$2 > $newStr:=$3 > $oldStrLen:=Length($oldStr) > $newstrlen:=Length($newStr) > > SET BLOB SIZE($blob;$oldlen*2+9;0) > $offset:=9 > $start:=1 > $count:=0 > Repeat > $pos:=Position($oldstr;$source;$start;*) > If ($pos>0) > $tempTxt:=Substring($source;$start;$pos-$start)+$newStr > $start:=$pos+$oldStrLen > If (Length($tempTxt)>0) > $offset2:=0 > VARIABLE TO BLOB($tempTxt;$blob2;$offset2) > COPY BLOB($blob2;$blob;9;$offset;$offset2-9) > $offset:=$offset+$offset2-9 > End if > $count:=$count+1 > End if > Until ($pos=0) > > If ($count>0) > If ($start<=$oldlen) > $tempTxt:=Substring($source;$start) > If (Length($tempTxt)>0) > $offset2:=0 > VARIABLE TO BLOB($tempTxt;$blob2;$offset2) > COPY BLOB($blob2;$blob;9;$offset;$offset2-9) > End if > End if > If ($oldStrlen>$NewStrLen) > $newLen:=$oldLen+(($NewStrLen-$oldStrLen)*$count) > SET BLOB SIZE($blob;$newlen*2+9) > Else > $newlen:=$oldLen > End if > > $blob{0x}:=Character code("R") > $blob{0x0001}:=Character code("V") > $blob{0x0002}:=Character code("L") > $blob{0x0003}:=Character code("B") > $blob{0x0004}:=0x0021 > $blob{0x0005}:=$newlen%256 > $blob{0x0006}:=($newlen\256)%256 > $blob{0x0007}:=($newlen\65536)%256 > $blob{0x0008}:=($newlen\16777216) > $offset:=0 > BLOB TO VARIABLE($blob;$result;$offset) > $0:=$result > > Else > $0:=$1 > End if > > If (Count parameters>3) > $4->:=$count > End if > > Alan Chan > > 4D iNug Technical <4d_tech@lists.4d.com> writes: >> $Source:=Replace String($Source;Char(9);"";*) >> >> Doesn't look so bad, does it? >> Turns out there are over 550,000 tabs in the text. >> Replace String, did indeed (eventually) return, but it took about 30 >> minutes. > > ** > 4D Internet Users Group (4D iNUG) > FAQ: http://lists.4d.com/faqnug.html > Archive: http://lists.4d.com/archives.html > Options: http://lists.4d.com/mailman/options/4d_tech > Unsub: mailto:4d_tech-unsubscr...@lists.4d.com > ** --- Gas is for washing parts Alcohol is for drinkin' Nitromethane is for racing ** 4D Internet Users Group (4D iNUG) FAQ: http://lists.4d.com/faqnug.html Archive: http://lists.4d.com/archives.html Options: http://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
Re: v13 (+?) - Replace String [warning]
Hi Chip, Try the following and it should be done in a second or 2 (compiled). //ES_ReplaceStr_Shrink($source;$oldString;$newString;{$count pointer})->Resulted text C_TEXT($0;$1;$2;$3;$source;$oldStr;$newStr;$result;$tempTxt) C_POINTER($4) C_LONGINT($oldLen;$newLen;$oldStrLen;$NewStrLen;$count;$offset;$offset2;$start;$pos) C_BLOB($blob;$blob2) $source:=$1 $oldLen:=Length($source) //$source is the source text $oldStr:=$2 $newStr:=$3 $oldStrLen:=Length($oldStr) $newstrlen:=Length($newStr) SET BLOB SIZE($blob;$oldlen*2+9;0) $offset:=9 $start:=1 $count:=0 Repeat $pos:=Position($oldstr;$source;$start;*) If ($pos>0) $tempTxt:=Substring($source;$start;$pos-$start)+$newStr $start:=$pos+$oldStrLen If (Length($tempTxt)>0) $offset2:=0 VARIABLE TO BLOB($tempTxt;$blob2;$offset2) COPY BLOB($blob2;$blob;9;$offset;$offset2-9) $offset:=$offset+$offset2-9 End if $count:=$count+1 End if Until ($pos=0) If ($count>0) If ($start<=$oldlen) $tempTxt:=Substring($source;$start) If (Length($tempTxt)>0) $offset2:=0 VARIABLE TO BLOB($tempTxt;$blob2;$offset2) COPY BLOB($blob2;$blob;9;$offset;$offset2-9) End if End if If ($oldStrlen>$NewStrLen) $newLen:=$oldLen+(($NewStrLen-$oldStrLen)*$count) SET BLOB SIZE($blob;$newlen*2+9) Else $newlen:=$oldLen End if $blob{0x}:=Character code("R") $blob{0x0001}:=Character code("V") $blob{0x0002}:=Character code("L") $blob{0x0003}:=Character code("B") $blob{0x0004}:=0x0021 $blob{0x0005}:=$newlen%256 $blob{0x0006}:=($newlen\256)%256 $blob{0x0007}:=($newlen\65536)%256 $blob{0x0008}:=($newlen\16777216) $offset:=0 BLOB TO VARIABLE($blob;$result;$offset) $0:=$result Else $0:=$1 End if If (Count parameters>3) $4->:=$count End if Alan Chan 4D iNug Technical <4d_tech@lists.4d.com> writes: >$Source:=Replace String($Source;Char(9);"";*) > >Doesn't look so bad, does it? >Turns out there are over 550,000 tabs in the text. >Replace String, did indeed (eventually) return, but it took about 30 >minutes. ** 4D Internet Users Group (4D iNUG) FAQ: http://lists.4d.com/faqnug.html Archive: http://lists.4d.com/archives.html Options: http://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
Re: v13 (+?) - Replace String [warning]
It was lunch time any way :) On Tue, 27 Jun 2017 22:59:01 +0200, Arnaud de Montard via 4D_Tech wrote: >> >> [...] >> I have a 4.8 meg text, I am using for testing. >> I accidentally ran the following line of code against it. >> >> $Source:=Replace String($Source;Char(9);"";*) >> >> [...] it took about 30 minutes. > > > Hi Chip, > you're more patient than me ;-) --- Gas is for washing parts Alcohol is for drinkin' Nitromethane is for racing ** 4D Internet Users Group (4D iNUG) FAQ: http://lists.4d.com/faqnug.html Archive: http://lists.4d.com/archives.html Options: http://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
v13 (+?) - Replace String [warning]
I was playing around with the code StringOmit from Keith Culotta. I made some changes, which should make it faster... still testing. but in the process I found a 'problem' with Replace String. I have a 4.8 meg text, I am using for testing. I accidentally ran the following line of code against it. $Source:=Replace String($Source;Char(9);"";*) Doesn't look so bad, does it? Turns out there are over 550,000 tabs in the text. Replace String, did indeed (eventually) return, but it took about 30 minutes. So You might want to watch out for number of occurrences of a character you are replacing, and how large the source is. Chip --- Gas is for washing parts Alcohol is for drinkin' Nitromethane is for racing ** 4D Internet Users Group (4D iNUG) FAQ: http://lists.4d.com/faqnug.html Archive: http://lists.4d.com/archives.html Options: http://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **