Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Dynamic Autosearch

edited September 2005 in General
Hello,

Why are there two enumerated types with the same meaning ?

TppSearchOperatorType = (soEqual, soNotEqual,
soLessThan, soLessThanOrEqualTo,
soGreaterThan, soGreaterThanOrEqualTo,
soLike, soNotLike,
soBetween, soNotBetween,
soInList, soNotInList,
soBlank, soNotBlank);

TdaCriteriaOperatorType = (dacoEqual, dacoNotEqual,
dacoLessThan, dacoLessThanOrEqualTo,
dacoGreaterThan, dacoGreaterThanOrEqualTo,
dacoLike, dacoNotLike,
dacoBetween, dacoNotBetween,
dacoInList, dacoNotInList,
dacoBlank, dacoNotBlank);

I am writing a procedure that set the value of an autosearch field at
runtime.
If the autosearch field does not exist my procedure can, optionally,
create it.
When setting the as field operator I need to use TppSearchOperatorType
when creating the as field instead I need to use TdaCriteriaOperatorType
(since I use TdaSQLBuilder.SearchCriteria.AddAutoSearch, the version
with the enum)

Is it safe to simply cast one enum into the other, since they have the
same content?

Thanks bye
Nicola

Comments

  • edited September 2005
    I just saw that I can't use

    function AddAutoSearch(const aTableNameOrAlias: String; const
    aFieldNameOrAlias: String; aOperator: TdaCriteriaOperatorType; aValue:
    String): TdaCriteria; virtual; overload;

    because it is protected ! (I was fooled by the help...)

    So I must use this version (with operator in string format)


    function AddAutoSearch(const aTableNameOrAlias: String; const
    aFieldNameOrAlias: String; const aOperator: String; const aValue:
    String): TdaCriteria; virtual; overload;

    Given that I would need now a function to convert the operator string
    in a TppSearchOperatorType...
    well I can figure out myself but if was it already made.... better

    Thanks bye
    Nicola
  • edited September 2005

    Ok, great.

    I do not why the TppSearchOperatorType and TdaCriteriaOperatorType were
    created instead of just a single enum type. I think a direct typecast would
    work, if not an indirect one would. An enum type always has an inderlying
    ordinal value. You could convert one type to its ordinal value and then
    convert the ordinal value to the other enum type.



    --
    Nard Moseley
    Digital Metaphors Corporation
    http://www.digital-metaphors.com


    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.