Page 1 of 1 1
Topic Options
#133391 - 2005-02-05 04:39 PM SetOption('CaseSensitivity','on')
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I don't see much use of SetOption('CaseSensitivity','on') but I sometimes see strings converted with UCase(). Now we know that KiX by default, is case insensitive and that it can be made case sensitive either with SetOption('CaseSensitivity','on') or by doubling up == on compares.

The question that begs to be asked is what would be considered "best practice"? If using string compares in a UDF, do you assume that 'CaseSensitivity' is 'off'; do you save/set/restore the SetOption; or do you convert all strings used in compares with UCase() or LCase()?

We know that other SetOption()s like 'Explicit' and 'NoVarsInStrings' can either break UDFs or if used carelessly in the UDF, cause calling scripts to fail.

I know that if we add this to the list, the UDF "Standards Police" may have a hayday pestering contributors but still, it deserves a mention.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#133392 - 2005-02-05 06:35 PM Re: SetOption('CaseSensitivity','on')
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
As case sensitivity of off by default, I'd keep that as a standard. If case sensitivity is required for e.g. string comparisons, then either use '==' or switch it on temporarily. While NoVarsInStrings and Explicit have usage with regards to the cleanliness of coding in general, CaseSensitivity is more "esoteric" as it applies to just a specific situation of string comparisons.
_________________________
There are two types of vessels, submarines and targets.

Top
#133393 - 2005-02-07 09:53 AM Re: SetOption('CaseSensitivity','on')
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
I think generally the guideline should be something like:
  • Submitted UDFs may be written to assume that case sensitivity is "OFF" and need not advertise this as a requirement.
  • Submitted UDFs which require case sensitivity to be "ON" may change the setting within the UDF, but only if the setting is guaranteed to revert to it's previous state on exit in all cases.
  • Use of the case sensitive operator "==" to explicitly mark case sensitive comparisons is encouraged.


Having case sensitivity "ON" is such an unusual state that I think it is reasonable to require "ON" scripts to reset the state before calling UDFs where the coder wants the UDF to behave as case insensitive.

Top
#133394 - 2005-02-08 05:17 PM Re: SetOption('CaseSensitivity','on')
masken Offline
MM club member
*****

Registered: 2000-11-27
Posts: 1222
Loc: Gothenburg, Sweden
I think case sensitivity brings ALOT of learning steps and unnessesary complexity to KiX. Part of KiX's magic is it's easyness and low learing threshold, and therefore I think that case sensitivity should be banned unless absolutely necessary...
_________________________
The tart is out there

Top
#133395 - 2005-02-08 06:19 PM Re: SetOption('CaseSensitivity','on')
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I never did understand why Ruud put it in there.
Especially when it is so easy to use the case sensitive operator "==" but then maybe I am just myopic and it has further reaching implications with functions like AScan().
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#133396 - 2005-02-09 05:50 AM Re: SetOption('CaseSensitivity','on')
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
The problem starts when you have to evaluate expressions like
Code:

IF 'AA'<'aa'
ENDIF


e.g. as part of a sorting routine. Without case sesitivity, this would not evaluate to TRUE.
_________________________
There are two types of vessels, submarines and targets.

Top
#133397 - 2005-02-09 09:23 AM Re: SetOption('CaseSensitivity','on')
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Yup. Also applies to things like InStr().
Top
#133398 - 2005-02-09 03:31 PM Re: SetOption('CaseSensitivity','on')
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I knew I was putting my foot in my mouth and am looking for a way to extract it now.

This then leads back to my first question about "best practice". Do we convert case with LCase()/UCase() to be safe, save/set/restore CaseSensitivity, warn users that we ignore it, or just turn a blind eye to it?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#133399 - 2005-02-10 09:28 AM Re: SetOption('CaseSensitivity','on')
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Quote:

This then leads back to my first question about "best practice". Do we convert case with LCase()/UCase() to be safe, save/set/restore CaseSensitivity, warn users that we ignore it, or just turn a blind eye to it?




I refer m'learned friend to my first reply, post#3, which preserves the status quo.

Top
Page 1 of 1 1


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.072 seconds in which 0.038 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org