Subject Re: canOpen firing twice for DMD's query object + unexpected =/==
From Gaetano <gaetanodd@hotmail.com>
Date Sat, 19 Sep 2020 06:26:56 +1000
Newsgroups dbase.getting-started


Hi Mervyn,

I guess now I know why the pro's use == where I couldn't see a reason
for it.

Thanks for looking it up!

Cheers,
Gaetano.

On 18/09/2020 18:34, Mervyn Bick wrote:
> On 2020/09/17 03:07, Gaetano wrote:
>
>> In the following code, if I change the "==" operator to "=" in the DO
>> CASE block, the first DO CASE clause evaluates to true (i.e. the code
>> sees _app.varSQL as being an empty string) and cSQL doesn't get
>> updated as I expected it to in the second CASE clause.
>>
>> I believe that the clause should not evaluate to true because
>> _app.cVarSQL is set to "getMissDaysDetails" and doesn't have any
>> trailing/inbetween/leading spaces. Any idea why the single "=" is not
>> working in that context?
>>
>
> This is a known "gotcha". :-)
>
> With EXACT set OFF (the default and recommended setting) the = symbol is
> equivalent to "begins with".
>
> According to the help file entry for = all strings begin with an empty
> string so ""=_app.cVarSQL will always return true.  It recommends
> testing for  _app.cVarSQL=""
>
> The alternative is to use the == exactly equals symbol as you have done
> or case empty(_app.cVarSQL)
>
> Mervyn.
>