BlobToBlob - code to copy a Blob directly to another Blob

There was a conversation on Skype CW-Talk about a loop to copy one table to another, where the tables included a blob.

It was pointed out that StringTheory has code that does this fairly cleanly
However that approach has the extra overhead of copying the entire blob to an intermediate string

ST StringTheory
  CODE 
  ST.FromBlob( MyFile.MyBlob )
  ST.ToBlob( OtherFile.MyBlob )

So I wrote the following BlobToBlob code with @Bruce Johnsons help

BlobToBlob PROCEDURE(*BLOB xTo, *BLOB xFrom)
FromSize ULONG,AUTO 
  CODE
  FromSize = xFrom{PROP:Size}
  xTo{PROP:Size} = 0   ! Important, even when later setting to FromSize
  IF FromSize > 0
     xTo{PROP:Size} = FromSize
     xTo[ 0 :  FromSize - 1] = xFrom[ 0 : FromSize - 1 ]
  END   

In my opinion it would be nice to see this added to SV’s Libsrc\Win\CWUtil.clw
where FileToBlob and BlobToFile appear

Regarding the “extra” xTo{PROP:Size} = 0
I asked @Bruce what happens if this is skipped, His response was:

In MSSQL for example, the later assignment will fail, or “explode” to 64K.
Let’s just say “not good things”.
The Clarion docs make it explicit that it must be set to 0, but it’s not intuitive.

yeah, for easier, and less error-prone blob handling I recommend using StringTheory or MyTable (or both). Hand-code on blob fields can quickly become complicated, and prone to errors. It would be nice if there was a strong Blob handling library in the Clarion box, but failing that MyTable is the best option.
https://www.capesoft.com/accessories/mytablesp.htm

For simple blob assignments the StringTheory methods FromBlob, and ToBlob are recommended.
https://www.capesoft.com/docs/StringTheory3/StringTheory.htm#FromBlob