4D v16.3

REAL TO BLOB

Home

 
4D v16.3
REAL TO BLOB

REAL TO BLOB 


 

REAL TO BLOB ( real ; blob ; realFormat {; offset | *} )  
Parameter Type   Description
real  Real in Real value to write into the BLOB
blob  BLOB in BLOB to receive the Real value
realFormat  Longint in 0 Native real format 1 Extended real format 2 Macintosh Double real format 3 Windows Double real format
offset | *  Variable, Operator in Offset within the BLOB (expressed in bytes) or * to append the value
in New offset after writing if not *

The REAL TO BLOB command writes the Real value real into the BLOB blob.

The realFormat parameter fixes the internal format and byte ordering of the Real value to be written. You pass one of the following predefined constants provided by 4D:

Constant Type Value
Extended real format Longint 1
Macintosh double real format Longint 2
Native real format Longint 0
PC double real format Longint 3

Platform Independence Note: If you exchange BLOBs between Macintosh and PC platforms, it is up to you to manage real formats and byte swapping issues when using this command.

If you specify the * optional parameter, the Real 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 or the offset variable parameter, the Real 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 Real value is written at the offset (starting from zero) within the BLOB. No matter where you write the Real value, the size of the BLOB is increased according to the location you passed (plus up to 8 or 10 bytes, 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. Therefore, you can reuse that same variable with another BLOB writing command to write another value.

After executing this code:

 C_REAL(vrValue)
 vrValue:=...
 REAL TO BLOB(vrValue;vxBlob;Native real format)
  • On all platforms, the size of vxBlob is 8 bytes

After executing this code:

 C_REAL(vrValue)
 vrValue:=...
 REAL TO BLOB(vrValue;vxBlob;Extended real format)
  • On all platforms, the size of vxBlob is 10 bytes

After executing this code:

 C_REAL(vrValue)
 vrValue:=...
 REAL TO BLOB(vrValue;vxBlob;Macintosh double real format` or Windows double real format
  • On all platforms, the size of vxBlob is 8 bytes

After executing this code:

 SET BLOB SIZE(vxBlob;100)
 C_REAL(vrValue)
 vrValue:=...
 INTEGER TO BLOB(vrValue;vxBlob;PC double real format` or Macintosh double real format
  • On all platforms, the size of vxBlob is 8 bytes

After executing this code:

 SET BLOB SIZE(vxBlob;100)
 REAL TO BLOB(vrValue;vxBlob;Extended real format;*)
  • On all platforms, the size of vxBlob is 110 bytes
  • On all platforms, the real value is stored at the bytes #100 to #109
  • The other bytes of the BLOB are left unchanged

After executing this code:

 SET BLOB SIZE(vxBlob;100)
 C_REAL(vrValue)
 vrValue:=...
 vlOffset:=50
 REAL TO BLOB(vrValue;vxBlob;PC double real format;vlOffset` or Macintosh double real format
  • On all platforms, the size of vxBlob is 100 bytes
  • On all platforms, the real value is stored in the bytes #50 to #57
  • The other bytes of the BLOB are left unchanged
  • The variable vlOffset has been incremented by 8 (and is now equal to 58)



See also 

BLOB to integer
BLOB to longint
BLOB to real
BLOB to text
INTEGER TO BLOB
LONGINT TO BLOB
TEXT TO BLOB

 
PROPERTIES 

Product: 4D
Theme: BLOB
Number: 552

This command can be run in preemptive processes

 
HISTORY 

Created: 4D v6

 
TAGS 

Real, Byteswapping

 
ARTICLE USAGE

4D Language Reference ( 4D v16)
4D Language Reference ( 4D v16.1)
4D Language Reference ( 4D v16.2)
4D Language Reference ( 4D v16.3)