TEXT TO BLOB

4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next

version 6.0


TEXT TO BLOB (text; blob; textFormat{; offset | *})

ParameterTypeDescription
textStringText value to write into the BLOB
blobBLOBBLOB to receive the text value
textFormatNumber0  C String
1  Pascal String
2  Text with length
3  Text without length
offset | *Variable | *Offset within the BLOB (expressed in bytes)
or * to append the value
New offset after writing if not *

Description

The TEXT TO BLOB command writes the Text value text into the BLOB blob.

The textFormat parameter fixes the internal format of the text value to be written. You pass one of the following predefined constants provided by 4th Dimension:

ConstantTypeValue
C stringLong Integer0
Pascal stringLong Integer1
Text with lengthLong Integer2
Text without lengthLong Integer3

The following table describes each of these formats:

Text formatDescription and Examples
C string The text is ended by a NULL character (ASCII code $00)
"" $00
"Hello World!" $48 65 6C 6C 6F 20 57 6F 72 6C 64 21 00
Pascal stringThe text is preceded by a 1-byte length
"" $00
"Hello World!" $0C 48 65 6C 6C 6F 20 57 6F 72 6C 64 21
Text with lengthThe text is preceded by a 2-byte length
"" $00 00
"Hello World!" $00 0C 48 65 6C 6C 6F 20 57 6F 72 6C 64 21
Text without lengthThe text is composed only of its characters.
"" No data
"Hello World!" $48 65 6C 6C 6F 20 57 6F 72 6C 64 21

Note: The command accepts both Text (declared with C_TEXT) and String (declared with C_STRING) expressions. Remember that a Text variable can contain up to 32,000 characters and a String variable can contain up to the number of characters in its declaration, with a maximum of 255 characters.

If you specify the * optional parameter, the Text value is appended to the BLOB; the size of the BLOB is extended accordingly. Using the * optional parameter, you can sequentially store any number of Integer, Long Integer, Real or Text values (see other BLOB commands) in a BLOB, as long as the BLOB fits into memory.

If you do not specify the * optional parameter nor the offset variable parameter, the Text value is stored at the beginning of the BLOB, overriding its previous contents; the size of the BLOB is adjusted accordingly.

If you pass the offset variable parameter, the Text value is written at the offset (starting from zero) within the BLOB. No matter where you write the Text value, the size of the BLOB is, increased according to the location you passed (plus up to the size of the text, if necessary). New allocated bytes, other than the ones you are writing, are initialized to zero.

After the call, the offset variable parameter is returned, incremented by the number of bytes that have been written. Therfore, you can reuse that same variable with another BLOB writing command to write another value.

Example

After executing this code:

   SET BLOB SIZE (vxBlob;0)
   C_TEXT (vtValue)
   vtValue := "Hello World!"  ` Length of vtValue is 12 bytes
   TEXT TO BLOB (vtValue;vxBlob;C string)  ` Size of BLOB becomes 13 bytes
   TEXT TO BLOB (vtValue;vxBlob;Pascal string)  ` Size of BLOB becomes 13 bytes
   TEXT TO BLOB (vtValue;vxBlob;Text with length)  ` Size of BLOB becomes 14 bytes
   TEXT TO BLOB (vtValue;vxBlob;Text without length)  ` Size of BLOB becomes 12 bytes

See Also

BLOB to integer, BLOB to longint, BLOB to real, BLOB to text, INTEGER TO BLOB, LONGINT TO BLOB, REAL TO BLOB.


4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next