例如:
 case strname of
  filename:;
 end;
中strname 的定义为
 const strname: WideString;
 filename的定义为
  const strname: String 类型
在执行时报
[Error] ViewUnit.pas(2099): Ordinal type required
[Error] ViewUnit.pas(2100): Incompatible types: 'Integer' and 'String'
怎么解决?
谢!

解决方案 »

  1.   

    case of 必须是有序数
    你可以使用数组
      

  2.   

    CASE OF 这里不能是一个STRING;
      

  3.   

    case of 必须是有序类型,不能用于字符传
      

  4.   

    在Delphi中的Case中的变量不能为字符型,将字符映射成数值型的吧!
      

  5.   

    用stringlist存取string类型,再通过case stringlist.indexof() of来进行条件选择。具体如下:
      str:=TStringList.Create;
      str.Add('china');
      str.Add('chile');
      case str.IndexOf(Edit1.Text) of
      0:showmessage('first');
      1:showmessage('second')
      

  6.   

    谢谢!
    因为工作原因,最近要用delphi,所以有很多问题不懂(以前是用VC的)。
    通过大家的帮忙,搞定了。