Alaska Software Inc. - Var2Bin Bin2Var errs!
Username: Password:
AuthorTopic: Var2Bin Bin2Var errs!
Itai Ben-ArtziVar2Bin Bin2Var errs!
on Sat, 12 Dec 2020 17:23:21 -0800
Hi Alaska,
Writing and reading an array is usually works well, but sometimes it
errs with the following error:
"No XPF-format or incompatible version number"
What conditions cause this error?

          *
Example:
aScatterAP is an array
"SCATTERAP" is a memo filed (DBE=DBFCDX)

The following code works well, but randomly yields a runtime error:
(nTempArea)->(FieldWPut("SCATTERAP", Var2Bin(aScatterAP) ))
aTemp  := Bin2Var((nTempArea)->(FieldWGet('SCATTERAP')))
          *

Many thanks,
-Itai
Andreas Gehrs-Pahl
Re: Var2Bin Bin2Var errs!
on Sun, 13 Dec 2020 04:07:11 -0500
Itai,

>"SCATTERAP" is a memo filed (DBE=DBFCDX)

You can't save binary data in a DBF "M" Memo Field! You need to either use 
a Binary Type Field (FOXDBE Field Types "V" -- Binary Memo, "X" -- Binary 
Character or "Z" -- Binary VarChar), or encode the binary value into a 
(printable) character string, using Base64, UUEncoded, QuotedPrintable, 
or something similar.

Xbase++ has routines for that, including Bin2Base64(), Bin2UUE(), and 
Bin2QP(), as well as their reverse Base642Bin(), UUE2Bin(), and QP2Bin().

>The following code works well, but randomly yields a runtime error:
>(nTempArea)->(FieldWPut("SCATTERAP", +aScatterAP) ))
>aTemp  := Bin2Var((nTempArea)->(FieldWGet('SCATTERAP')))

The reason is that any number of control characters in your binary value, 
like chr(0), but especially chr(26) -- which terminates memo fields -- will 
result in corrupted or truncated memo field data.

Andreas

Andreas Gehrs-Pahl
Absolute Software, LLC

phone: (989) 723-9927
email: Andreas@AbsoluteSoftwareLLC.com
web:   http://www.AbsoluteSoftwareLLC.com
[L]:   https://www.LinkedIn.com/in/AndreasGehrsPahl
[F]:   https://www.FaceBook.com/AbsoluteSoftwareLLC
Itai Ben-ArtziRe: Var2Bin Bin2Var errs!
on Tue, 15 Dec 2020 09:00:10 -0800
Andreas,
OK.  I've got it. Thanks!
BTW, it was working for alright with the exception of a single record.