Hi,
I am now working on fcl-db TBinaryField, which has Value: Variant property.
As I understand documentation, this variant should be returned as variant array of bytes.

Later when are assigning values of fields into params also this variant array is copied (into TParam).

But when I want/need read parameter value as string (binary string) then "variant convert error" occurs. It is because in cvarutil.inc in Function VariantToAnsiString(const VargSrc : TVarData) is not supported conversion from variant array into string.

So my question is if it is acceptable to add there support for converting byte array to string ?
Something like attached diff.

Please let me know, if this can be accepted/applied ?
Thanks
-Laco.
--- cvarutil.inc.ori    Thu Apr 07 06:10:54 2011
+++ cvarutil.inc        Fri Oct 21 11:04:44 2011
@@ -1415,7 +1415,12 @@ begin
       end else { pointer is nil }
         VariantTypeMismatch(vType, varString);
     else { array or something like that }
-      VariantTypeMismatch(vType, varString);
+      if (vType and varArray = varArray) and Assigned(vArray) then begin
+        SetLength(Result, vArray^.Bounds[0].ElementCount * 
vArray^.ElementSize);
+        Move(vArray^.Data^, Result[1], length(Result)*sizeof(AnsiChar));
+      end
+      else
+        VariantTypeMismatch(vType, varString);
     end;
 
   {$IFDEF DEBUG_VARUTILS} if __DEBUG_VARUTILS then begin
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to