case MyColor of  Red: X := 1;
  Green: X := 2;
  Blue: X := 3;
  Yellow, Orange, Black: X := 0;
end;I真的都是有序类型吗??

解决方案 »

  1.   

    在做一个财务软件,有一个判断税金(Currency类型)的计算字段,想用case方便一些。不过现在改用if了。没问题了,多谢大家。但还是想知道用case是不是可以判断实型。
      

  2.   

    想知道用case是不是可以判断实型。
      

  3.   

    不可以不过可以转换成对应的整型再判断(如果有规律可循)
    例如,实型的间隔是固定的
    value=
    0-2.0   (0 <= value < 2.0)
    2.0-4.0
    4.0-6.0
    分别对应不同的情况:case trunc(value/2.0) of
        0: ...; //0-2.0
        1: ...; //2.0-4.0
        2: ...; //4.0-6.0
    end
      

  4.   

    Case when ....then ....else 
                           case ..of . then ....end 
    end
      

  5.   

    不可以。
    但是你可以用case( integer(value) )
      

  6.   

    if ... then
    else if ... then
    else if ... then
    else
    ....