Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Set contents

how do i write the contents of a set to the screen when writing a console application? i read my books and it doesn't mention it.

thanks :)

Comments

  • zibadianzibadian Member Posts: 6,349
    : how do i write the contents of a set to the screen when writing a console application? i read my books and it doesn't mention it.
    :
    : thanks :)
    :
    For writing to the screen in a console you need to use write() or writeln().
    A set cannot be directly written to the screen as you would a string or an integer, but you can use a number of if-then statements:
    [code]
    if SomeSetValue1 in SomeSet then
    write('Value 1 is set');
    if SomeSetValue2 in SomeSet then
    write('Value 2 is set');
    etc.
    [/code]
  • mudfoxmudfox Member Posts: 5
    problem is i have loads of items in each set. and it wud require a lot of if statements. The sets are just letters. One set of uppercase, one set of lowercase, on set of vowels. I want to write all the uppercase vowels, the non uppercase characters which aren't vvowels.. etc..
  • zibadianzibadian Member Posts: 6,349
    [b][red]This message was edited by zibadian at 2003-11-5 2:59:47[/red][/b][hr]
    : problem is i have loads of items in each set. and it wud require a lot of if statements. The sets are just letters. One set of uppercase, one set of lowercase, on set of vowels. I want to write all the uppercase vowels, the non uppercase characters which aren't vvowels.. etc..
    :
    I cannot help you more direct without seeing your set definitions.
    If you have defined your sets as "set of char" or "set of {char-subrange}" you can use a for do loop to reduce the number of if-statements. Here's an example:
    [code]
    var
    TestSet: set of char;
    i: char;
    begin
    TestSet := ['a'..'z']; // only lower cases
    for i := Low(Char) to High(Char) do
    if i in TestSet then
    write(i);
    end;
    [/code]
Sign In or Register to comment.