Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to build sets of letters for the currently selected language Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
30-Aug-02
Category
Others
Language
Delphi 2.x
Views
140
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

Is there any way to enumerate the contents of a set? Just now I have a set of char, 
each char is a lower case character, and need to add the corresponding upper case 
characters to the set. Any other way than looping through the set range and do an 
inclusion check each time?

Answer:

No. If you are after building sets of letters for the currently selected language 
you could do it using API functions like IsCharAlpha and IsCharUpper:


1   unit Charsets;
2   
3   interface
4   
5   type
6     TCharSet = set of AnsiChar;
7   
8   const
9     Signs: TCharset = ['-', '+'];
10    Numerals: TCharset = ['0'..'9'];
11    HexNumerals: TCharset = ['A'..'F', 'a'..'f', '0'..'9'];
12    IntegerChars: TCharset = ['0'..'9', '-', '+'];
13  var
14    Letters, LowerCaseLetters, UpperCaseLetters: TCharSet;
15    FloatChars, SciFloatChars: TCharset;
16    AlphaNum, NonAlphaNum: TCharset;
17  
18    { Need to call this again when locale changes.  }
19  procedure SetupCharsets;
20  
21  implementation
22  
23  uses
24    Windows, Sysutils;
25  
26  procedure SetupCharsets;
27  var
28    ch: AnsiChar;
29  begin
30    LowerCaseLetters := [];
31    UpperCaseLetters := [];
32    AlphaNum := [];
33    NonAlphaNum := [];
34    for ch := Low(ch) to High(ch) do
35    begin
36      if IsCharAlpha(ch) then
37        if IsCharUpper(ch) then
38          Include(UpperCaseLetters, ch)
39        else
40          Include(LowerCaseLetters, ch);
41      if IsCharAlphanumeric(ch) then
42        Include(AlphaNum, ch)
43      else
44        Include(NonAlphaNum, ch);
45    end;
46    Letters := LowerCaseLetters + UpperCaseLetters;
47    FloatChars := IntegerChars;
48    Include(FloatChars, DecimalSeparator);
49    SciFloatChars := FloatChars + ['e', 'E'];
50  end;
51  
52  initialization
53    SetupCharsets;
54  
55  end.


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC