KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Replacing a text string in a BLOB
PRODUCT: 4D | VERSION: 2004 | PLATFORM: Mac & Win
Published On: May 5, 2006

This method finds and replaces a text string ($1) with an another text string ($2) within a BLOB pointed to with $3. FindInBlob method used in this method is located in the tech tip #32979.

  ` ----------------------------------------------------
  ` Method: ReplaceString
  ` $1 - old string
  ` $2 - new string
  ` $3 - pointer to blob
  ` ----------------------------------------------------


C_LONGINT($stringStart;$stringEnd;$newstringLength)
C_TEXT($1;$stringName)
C_TEXT($2;$newstring)
C_POINTER($3)

$stringName:=$1
$newstring:=$2

$stringStart:=FindInBlob ($3->;$stringName)

DELETE FROM BLOB($3->;$stringStart;Length($stringName))

$newstringLength:=Length($newstring)
INSERT IN BLOB($3->;$stringStart;$newstringLength)
TEXT TO BLOB($newstring;$3->;Text without length ;$stringStart)