KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Splitting large blobs into smaller chunks
PRODUCT: 4D | VERSION: 2003 | PLATFORM: Mac & Win
Published On: April 8, 2004
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

Compatibility: Version 6.8.x and 2003.x

Here's a useful method to use if you are handling large blobs containing text that needs to be manipulated in small streams of text. This method will break a blob down into an array of text.

C_POINTER($1)
C_POINTER($2)
C_LONGINT($blobSize;$limitSize)
C_LONGINT($elemNum)
C_LONGINT($offset;$0)

  :` we want a 20,000 character text buffer

$limitSize:=20000
$elemNum:=0
$offset:=0

$blobSize:=BLOB size($1->)

` insert the first text blob
Repeat
  INSERT ELEMENT($2->;Size of array($2->)+1)
  $2->{Size of array($2->)}:=BLOB to text($1->;Text without length ;$offset;$limitSize)
  $offset:=$limitSize
  $blobSize:=$blobSize-$offset
Until ($blobSize<=0)

` return the number of elements added
$0:=Size of array($2->)