Results 1 to 2 of 2

Thread: Select UCase <String>

  1. #1
    thinBasic MVPs ReneMiner's Avatar
    Join Date
    Oct 2012
    Location
    Germany
    Age
    51
    Posts
    1,444
    Blog Entries
    2
    Rep Power
    160

    Select UCase <String>

    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
    Last edited by ReneMiner; 11-03-2021 at 17:09. Reason: something wrong with the styles...

  2. #2
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,090
    Blog Entries
    5
    Rep Power
    727
    Dear Rene,

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


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

Similar Threads

  1. Select
    By Charles Pegge in forum O2h Compiler
    Replies: 0
    Last Post: 18-03-2009, 08:44
  2. Usage of the LCASE$ MCASE$ UCASE$ Keywords
    By Michael Clease in forum Samples for help file
    Replies: 6
    Last Post: 28-05-2007, 11:51
  3. combobox select
    By sandyrepope in forum Fixed or cleared errors in help material
    Replies: 0
    Last Post: 25-03-2007, 06:19

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •