Board index » delphi » Strange behaviour of variant to single
Eef Vrije
![]() Delphi Developer |
Strange behaviour of variant to single2006-05-20 01:46:41 AM delphi94 Hi dear reader I have a strange problem which I can not resolve by myself: A function returning a Variant value stores it is return value into a variable of type Single: Function GetValue(Params):Variant; Begin ... Use Params to locate a table and Field in an Access database ... Determine the field type and retrieve the field-value: Result := Table.FieldByName(..).AsString, or .AsFloat etc. End; In another procedure I use: Var LSize, LSize1, LSize2 : Single; LSize1 := GetValue(Tablename1, Fieldname1); LSize2 := GetValue(Tablename1, Fieldname2); ... LSize := GetValue(Tablename2, Fieldname3); LSize1 and 2 are filled correctly, whilest LSize always remains 0, although GetValue really returned a value. Changing the name of variable LSize into for example XSize has no effect. Changing the place of the LSize declaration in the Var-Section doesn't help either. When I change the code to XVariant := GetValue(Tablename2, Fieldname3); LSize := XVariant; I can see that XVariant is filled with the proper value. LSize itself still does not! Even worse: In this code the second line is not even compiled. Viewing the code in the CPU-Window I noticed that for LSize1 and 2 the call to GetValue is followed by a call to a VariantManager. For the LSize after the call to GetValue is followed only by a single fst(0) statement . What can I do to make sure that LSize will be properly filled?? And ... I have used this construction a lot of times in my progam. At this point I do not trust them anymore. By the way, I am using Delphi 6 and connecting to an Access/SQL databse through an ADO connection. Thanks E. Vrije |