PDA

View Full Version : Select UCase <String>



ReneMiner
11-03-2021, 16:03
since the keyword UCase already is defined in context Collate UCase for Array-functions
- do not confuse it with UCase$()-function -
i wonder if it would be reasonable to shorten it for selecting matching literal string
content.
Lets think of "UCase" not as "UPPER Case" but as "UNIFORM Case"

It could allow us to have some additional string-Case-parameters
that are all boolean keywords of core-module already
(StartsWith, EndsWith, Contains, IsLike, IsUnicode, IsUTF8 )
and hopefully some sort of Matches "<-- regular expession -->"

As its possible to define a range of Cases for numeric expressions to select from,
using comma separated ranges (n1 to n2, n3, n4 to n5...)


for Strings where literal content matters (UCase) but not binary value -
it could describe multiconditional Cases using the operators AND, OR, NOT

Would it work faster than ordinary "Select Case"
if thincore would not have to determine the type of case to select
when the Keyword

UCase -instead of Case-


mandatory implicates a string to test in non-sensitive mode and "Select UCase"
would require a variable and not an expression to test?


In any case - it were muchos simplicados for programmers to check and identify tokens
that come from user input or other diferent sources that do not follow strictly all to the same rules.




Select Case UCase$(StringExpression)
Case "exact matching content only"

Case Else

End Select





Improve to insensitive string-selection
- the first matching case is performed only


example Cases for Select UCase
( lower Case chars in Cases description beween the quotes are literally valid - no error






Select UCase myVar$ ' encoding by default AscII assumed



Case "HELLO"
' literal match full string content


Case StartsWith "ABC"
' 3 matching chars at start of SelectExpression


Case StartsWith "DEF", StartsWith "GHI"
' same as below:


Case StartsWith "DEF" Or StartsWith "GHI"
' also 3 chars at start match, either "abc" or "def"


Case StartsWith Any "AEIOU" AND Endswith "ION"
' first char matches a vocal, token ends with "ion"


Case StartsWith Any CHR$("0" to "9") AND Contains "." AND EndsWith "€"
' matching the first ascii/basic utf8 of the range in chr$(),
' its a numeral digit,
' contains a decimal seperator and ends with utf8-Euro symbol


Case IsUniCode AND Contains Any CHRW$("ä","ö","ü" )
' matches if unicode wide and the letters ÄÖÜ are contained


Case EndsWith "ION" And Not IsLike "*SCR???ION"
' would match "satisfaction" or "user-action""
' but not matching "Prescription", "Subscription" nor "description"


Case Contains "DEFGHIJKLMNOPQRSTUVW"
' match only if the above are contained exactly


Case Contains ANY "QRXZ"
' match if any char of q,r, x or z is contained'equal to


Case Contains "Q" or Contains "R" or contains "X" or contains "Z"


Case contains All "ZYXQ"'
'match if all chars are present. order does not matter
' same as


Case contains "Z" AND contains "Y" AND contains All "X" AND contains "Q"




Case Not "WORLD" AND NOT "HELLO"
' matches anything except literals "world" and "helllo"


Case NOT ""
' anything but not an empty string|nothing


Case Else
' all that was not handled above

End Select






perhaps its easier - but could lead to complications with Array-methods if keyword
UCase will be used instead of Case but also the users might produce bugs when they
start mixing Case with uCase as selection-opening-keyword

Petr Schreiber
17-03-2021, 08:24
Dear Rene,

very interesting idea, I like the super SELECT CASE! Even without the uniform part.


Petr