Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Turbo Pascal - <b> in inclusion operator pp 85</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 IN                          Inclusion Operator                        pp 85


 Define:  Relational operator for Set types.

 Purpose: In determines if Argument is a member of Set.

 Notes:   The In operator is faster than using a series of relational
          expressions linked with the Or operator.


 ----------------------------------------------------------------------------


 Usage:
       CONST
          Letters : Set of Char = ['A'..'Z'];     { Upper case letters     }
          Menu    : Set of Char = ['1','2','3'];  { Menu choices           }
       VAR
          Choice  : Char;                         { Input variable         }

       BEGIN
          If 'A' In Letters then                  { Continue if in set     }
            Begin
            ReadLn (Choice);                      { Get console input      }
            If Choice in Menu                     { If valid choice..      }
               Then WriteLn ('OK')                { Choice is in Menu set  }
               Else WriteLn ('Bad');              { Choice not in Menu set }
            End;
       END.

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson