Else in case statement

Discussion in 'Pascal Logic Code Examples' started by Dave Byron, Aug 29, 2006.

  1. Dave Byron

    Dave Byron

    Joined:
    Aug 3, 2004
    Messages:
    835
    Likes Received:
    0
    Location:
    Casurina
    In Piced I see there is no "else" in the case statement (like MS) so you can not have somthing like this;

    case operator of
    '*' : result:= number1 * number2;
    '/' : result:= number1 / number2;
    '+' : result:= number1 + number2;
    '-' : result:= number1 - number2;
    Else : result;
    end;

    Whats the best way of stopping the run time errors other than range checking before the case statement.

    dave
     
    Dave Byron, Aug 29, 2006
    #1
  2. Dave Byron

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    Adding an else clause is in our to do list (#7076).

    We are looking at removing the run time error for invalid cases, but currently you need to do a range check unfortunately.
     
    Darren, Aug 30, 2006
    #2
  3. Dave Byron

    [IL]NewGen

    Joined:
    Aug 3, 2004
    Messages:
    121
    Likes Received:
    0
    Location:
    Melb, Australia
    Yay !

    if <condition> then
    begin
    <Task or condition then>
    end
    else
    begin
    <Task or condition then>
    end;
    :D
     
    [IL]NewGen, Sep 2, 2008
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.