Board index » delphi » HELP! How do you display SET contents?

HELP! How do you display SET contents?

Help, please!
I have a SET of five char and I don't know how to display what the
characters are?  An example procedure would be appreciated, please?

 

Re:HELP! How do you display SET contents?


Quote
> I have a SET of five char and I don't know how to display what the
> characters are?  An example procedure would be appreciated, please?

   for I := 0 to 255 do
     if Chr(I) in set_variable then write (Chr(I),' is in the set.')

Re:HELP! How do you display SET contents?


In article <32469C60....@primenet.com> of Mon, 23 Sep 1996 07:40:02 in
comp.lang.pascal.borland, Mike Copeland <mrc...@primenet.com> wrote:

Quote
>> I have a SET of five char and I don't know how to display what the
>> characters are?  An example procedure would be appreciated, please?

>   for I := 0 to 255 do
>     if Chr(I) in set_variable then write (Chr(I),' is in the set.')

IMHO, a "bete noir(e)" - I suggest

for C := #0 to #255 do
  if C in set_variable then Write(C, ' is in the set.')

Let us use the nice features that Wirth et al have provided !

--
John Stockton, Surrey, UK.  J...@merlyn.demon.co.uk  Turnpike v1.12  MIME
    http://www.merlyn.demon.co.uk/pascal.htm#BadP

Re:HELP! How do you display SET contents?


Quote
spe...@dialnet.net (Spence) wrote:
>Help, please!
>I have a SET of five char and I don't know how to display what the
>characters are?  An example procedure would be appreciated, please?

Program PrintingSets;
{ Brute force approach.  <clifp...@airmail.net>  Turbo v.6.0
    9/27/96 }

TYPE
LowerCase = Set of 'a'..'z';

VAR
set1, set2, set3:LowerCase;

Procedure ShowSet(setp:LowerCase);
VAR
ch:Char;
Begin
     For ch := 'a' to 'z' Do
         If ch in setp then Write(ch, ' ');
     Writeln;
End;

Begin
     Writeln; Writeln; Writeln;

     set1 := ['a'..'k'];
     Write('set1 contains: ');
     ShowSet(set1);
     Writeln;

     set2 := ['d'..'f', 'j'..'m'];
     Write('set2 contains: ');
     ShowSet(set2);
     Writeln;

     set3 := set1 + set2;
     Write('The union of set1 and set2 is: ');
     ShowSet(set3);
     Writeln;

     set3 := set1 * set2;
     Write('The intersection of set1 and set2 is: ');
     ShowSet(set3);
     Writeln;

     set3 := set1 - set2;
     Write('set1 - set2 = ');
     ShowSet(set3);
     Writeln;

Write('End of demo. Press Enter.');  Readln;
End.

Re:HELP! How do you display SET contents?


Monday September 23 1996 08:06, Spence wrote to All:

 S> Help, please!
 S> I have a SET of five char and I don't know how to display what the
 S> characters are?  An example procedure would be appreciated, please?

Assuming environment of 12345 (SET 12345=ABCDE):
writeln(getenv(12345));

I *THINK*!!
Cann't remember for sure.

Dan [TEAM OS/2]

... ---------------** This tagline will self destruct in 7 seconds...

Other Threads