[comp.lang.pascal] Syntax of 'in'

ZCCBJSB%EB0UB011.BITNET@cunyvm.cuny.edu (Josep Sau B.) (04/30/91)

>> i fiddled, i faddled, i fuddled and then i posted a message for help.
>> of course after posting i decide to try ONE LAST THING, which was:
>>    repeat while upcase(key) not in ['A','B','H','W'];

>  What you probably saw was a set constructed as follows:
>     LetSetType = ['A'..'Z'];
>  Or something similar to that. This type of set will only work with
>  a contiguous subrange of a larger set.

Any char set constant may be used there, be it a contiguous
range or not.
I think the problem is the syntax of the 'IN' operator.
It takes two operands: the one in the left must be an ordinal,
and the one in the right a set of the same base type.
Try using:

  repeat until (upcase(key) in (.'A','B','H','W'.);

Moreover, the construct 'repeat... while...' is illegal in Pascal.
A REPEAT always matches an UNTIL, not a WHILE, and the loop
is exited if the condition is TRUE.

-- Josep Sau

ISPAJW@ASUACAD.BITNET (Andrew Wollert) (05/01/91)

To use 'not' with 'in' the following syntax is used:

repeat
 (* statements *)
until not ( UpCase(Key) in ['A', 'B', 'C']); (* or whatever *)

I'm using an IBM--my brackets may not show up.

--Andy