Tech Tip: Merging text files larger than 32K
PRODUCT: 4D | VERSION: 2004 | PLATFORM: Mac & Win
Published On: November 29, 2005
On rare ocassions, there is a need to merge documents that are larger than 32k, which makes text variables inadequate for this use. The following method uses BLOBs to accomplish a document merge, without using text variables at all:
` $file1 - path to source file
` $file2 - path to file that will be appended with source file
C_BLOB ($blob1, $blob2)
C_TEXT ($file1; $file2)
C_LONGINT($blobSize1;$blobSize2)
DOCUMENT TO BLOB($file1;$blob1)
DOCUMENT TO BLOB($file2;$blob2)
` Get BLOB sizes
$blobSize1:=BLOB size($blob1)
$blobSize2:=BLOB size($blob2)
` Resize destination blob and append it
SET BLOB SIZE($blob2;($blobSize1+$blobSize2))
COPY BLOB($blob1;$blob2;0;($blobSize2-1);$blobSize1)
` Write file
BLOB TO DOCUMENT ($file2; $blob2)