Hi Chip,

It depends on what you want to try to achieve with that command.
I’m using the code below to copy a complete 4D record binary into a blob. But 
the only thing you normally can do with the resulting blob is to put it back 
into a record.
AFAIK this is also the case with the API Pack (and OTools?) commands.

But in your pseudo code I noticed you add a 'convert to text' command. So the 
resulting blob would contain a textual representation of the record. But that 
would fail with binary fields like pictures, objects and blobs. 

This is my RecordToBlob method, which uses an intermediate file in the temp 
directory:
//usage: $blob:=RecordToBlob(->[myTable]myField)
C_POINTER($1;$tablePtr)
C_BLOB($0)
C_TEXT($path)

$tablePtr:=$1

If (Records in selection($tablePtr->)#0)
$path:=Temporary folder +"temp_rec_to_blob"+String(Current process)
SET CHANNEL(10;$path)
SEND RECORD($tablePtr->)
SET CHANNEL(11)

DOCUMENT TO BLOB($path;$0)
Else 
TRACE
End if 


And its BlobToRecord counterpart:
//usage: RecordToBlob($blob;->[myTable]myField)
C_BLOB($1;$blob)
C_POINTER($2;$tablePtr)

$blob:=$1
$tablePtr:=$2

$path:=4D_temp_path +"temp_rec_to_blob"+String(Current process)

BLOB TO DOCUMENT($path;$blob)

SET CHANNEL(10;$path)
RECEIVE RECORD($tablePtr->)
SET CHANNEL(11)
SAVE RECORD($tablePtr->)


Kind regards,
Koen

> Op 2 aug. 2017, om 20:20 heeft Chip Scheide via 4D_Tech 
> <[email protected]> het volgende geschreven:
> 
> is there simple way to move an entire (arbitrary) record to a blob?
> 
> I was hoping for a simple command like:
> Record to blob([table];Blob)



--------------------
Compass bvba
Koen Van Hooreweghe
Kloosterstraat 65
9910 Knesselare
Belgium
tel +32 495 511.653

**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to