On 13/11/2007, Marco van de Voort <[EMAIL PROTECTED]> wrote:
> On Tue, Nov 13, 2007 at 09:47:31AM +0200, Graeme Geldenhuys wrote:
> > What are your feelings about the use of Variants? I'm debating this
> > in another NG and would like some outside opinion.
>
> Use for what?
In tiOPF we have a Criteria unit that generates SQL 'where' clauses as
output. Currently that unit isn't used much - its still in the
development stages. My initial implementation only uses string types
- probably because my test app used TEdit text boxes as input and that
the required criteria output must always be in string format anyway.
So all methods handle strings parameters only. We now received a
patch which uses variants to support multiple types like floats, dates
etc...
The tiOPF project is normally against using Variants, so I hesitated
to commit the patch. So asked the question here, what others think of
variants.
eg of changes in patch...
- procedure AddBetween(AAttribute, AValue_1, AValue_2: string);
+ procedure AddBetween(AAttribute: string; AValue_1, AValue_2: variant);
- procedure AddEqualTo(AAttribute, AValue: string); overload;
- procedure AddEqualTo(AAttribute: string; AValue: integer); overload;
+ procedure AddEqualTo(AAttribute: string; AValue: variant); overload;
....
TPerBetweenCriteria = class(TPerValueCriteriaAbs)
private
- FValue_2: string;
+ FValue_2: variant;
public
- constructor Create(AAttribute, AArg_1, AArg_2: string; ANegative:
boolean = false; AFieldName: string = ''); reintroduce; virtual;
+ constructor Create(AAttribute: string; AArg_1, AArg_2: variant;
ANegative: boolean = false; AFieldName: string = ''); reintroduce;
virtual;
function GetClause: string; override;
published
- property Value_2: string read FValue_2;
+ property Value_2: variant read FValue_2;
end;
>
> They were never meant to be used as normal variables.
That's what I thought. And from the above patch snippet, I can't see
variants being justified.
Regards,
- Graeme -
_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives