DelphiBasics
In
Keyword
Used to test if a value is a member of a set
  Ordinal expression in Set expression
Description
The In keyword tests whether a value is in a set. It returns true if it is, false if not.
Notes
Sets are limited to 256 different values. Each element is equated with the Integer values 0,1,2 ... 255

Integer sets map directly to these element values, and are therefore limited to a high value of 255.

However, you may compare a value greater than 255 with an Integer set. Delphi simply uses the lowest byte of the Integer. For example, a test value of 258 would have a lower byte value of 3.
Related commands
Exclude Exclude a value in a set variable
Include Include a value in a set variable
Set Defines a set of up to 255 distinct values
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 Download this web site as a Windows program.




 
Example code : Determine whether a character is a letter
begin
  IsLetter('G');  // G is a letter of the (uppercase) alphabet
  IsLetter('1');  // 1 is not a letter
end;

// Test if a character is a letter
procedure TForm1.IsLetter(Letter : char);
var
  Alphabet : set of 'A'..'Z';

begin
  Alphabet := ['A'..'Z'];

  if Letter In Alphabet then
    ShowMessage(Letter+' is in the alphabet')
  else
    ShowMessage(Letter+' is NOT in the alphabet');
end;
Show full unit code
   G is in the alphabet
   1 is NOT in the alphabet
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Home Page