Blob to Record

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Blob to Record

4D Tech mailing list
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)

rather then
for(records)
  for(number of fields)
    convert to text(field)
    append text to blob  
  end for
  next
end for

---------------
Gas is for washing parts
Alcohol is for drinkin'
Nitromethane is for racing
**********************************************************************
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:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Blob to Record

4D Tech mailing list
API Pack has Record to BLOB and BLOB to record.


--
Douglas von Roeder
949-336-2902

On Wed, Aug 2, 2017 at 11:20 AM, Chip Scheide via 4D_Tech <
[hidden email]> wrote:

> 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)
>
> rather then
> for(records)
>   for(number of fields)
>     convert to text(field)
>     append text to blob
>   end for
>   next
> end for
>
> ---------------
> Gas is for washing parts
> Alcohol is for drinkin'
> Nitromethane is for racing
> **********************************************************************
> 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:[hidden email]
> **********************************************************************
**********************************************************************
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:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Blob to Record

4D Tech mailing list
In reply to this post by 4D Tech mailing list
Hi Chip,

> On 3 Aug 2017, at 04:20 AEST, Chip Scheide via 4D_Tech <[hidden email]> wrote:
>
> is there simple way to move an entire (arbitrary) record to a blob?

Maybe you should take a look at ObjectTools commands  OT PutRecord / OT PutRecord / OT GetRecordTable.

Cheers
Jörg
**********************************************************************
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:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Blob to Record

4D Tech mailing list
In reply to this post by 4D Tech mailing list
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 <[hidden email]> 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:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Blob to Record

4D Tech mailing list
THANKS

Actually, I'm not trying to do anything with this - at the moment.
I am working on a component for managing text, and a couple of routines
do records to text and record to blob/text, with the idea (no specific
implementation intent) of exporting to some other program/database.

I was thinking about this, and thought a 'Record to Blob' and 'blob to
record' would be useful/handy.

Thanks again
Chip
On Thu, 3 Aug 2017 14:37:46 +0200, Koen Van Hooreweghe via 4D_Tech
wrote:

> 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
>> <[hidden email]> 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:[hidden email]
> **********************************************************************
---------------
Gas is for washing parts
Alcohol is for drinkin'
Nitromethane is for racing
**********************************************************************
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:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Blob to Record

4D Tech mailing list
It would be very handy for a lot of different reasons. A few months ago, I added a feature request for it:

http://forums.4d.com/Post/EN/17757394/1/17757395#17757395

Please vote for it if you think it would be useful.

John DeSoi, Ph.D.




> On Aug 3, 2017, at 8:45 AM, Chip Scheide via 4D_Tech <[hidden email]> wrote:
>
> I was thinking about this, and thought a 'Record to Blob' and 'blob to
> record' would be useful/handy.

**********************************************************************
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:[hidden email]
**********************************************************************
Loading...