Tell me what you want, What you really, really want.

Moderator: Mmiscool

User avatar
By Electroguard
#56992 Testing for even a simple "No" flag has the 3 equally valid-looking responses of "no", "No", "NO", but only one will evaluate correctly - leading to a common source of bugs unless all IF tests are impractically tested for all spelling alternatives.

Therefore the addition of an 'ANYCASE()' function could make testing of variables more accurate and foolproof.


EXAMPLE: if Flag_Variable == ANYCASE(response) then gosub[IrrespectiveOfCase] 'would evaluate correctly whatever the case of the response variable.
User avatar
By Mmiscool
#57005 Use the upper() or lower() functions.

Code: Select allif upper(myvar) == "NO" then print "result true"


https://docs.google.com/document/d/1EiY ... b19oepqhyd
User avatar
By Electroguard
#57010 Yeah, that's how I have been doing it till now, but I just thought there may be a better way than converting sources variables before comparing to converted target variables, and the result still not an accurate representation of either of the variables case.
Ah well, back to the drawing board.
User avatar
By livetv
#57079 "... I just thought there may be a better way than converting sources variables before comparing to converted target variables..."

I do this:

if lower(response) == "no" then gosub [whyNot]

It seems to be nearly functionally identical to what is being requested. It does require that the "Flag_Variable" in the prior example be all lower case. If you are unsure that this will be the case, just do this:

if lower(response) == lower(Flag_Variable) then gosub [whyNot]

That will work just fine even if it does require two LOWER() functions.

If the intent was to have ANYCASE() resolve any differences between upper and lower case of both the Flag_Variable and the response variable when we don't always know what either might be, then we are out of the realm of a single argument function. We would have to have a function which takes two arguments and compares them OR create a new operator to do it. I would just use two LOWER() functions and be done with it!