unit AISMTypeUnt;interfaceconst
  otBrowse = '0000000001';
  otAdd ='0000000010';
  otDelete ='0000000100';
  otModify ='0000001000';
  otPrint ='0000010000';type
  TOptType=(otBrowse,otAdd,otDelete,otModify,otPrint);implementationend.错误如下:
[Error] AISMTypeUnt.pas(13): Identifier redeclared: 'otBrowse'
[Error] AISMTypeUnt.pas(13): Identifier redeclared: 'otDelete'
[Error] AISMTypeUnt.pas(13): Identifier redeclared: 'otPrint'
这为什么好错啊,为什么otadd就没有出错呢?
why?

解决方案 »

  1.   

    const
      1otBrowse = '0000000001';
      1otAdd ='0000000010';
      1otDelete ='0000000100';
      1otModify ='0000001000';
      1otPrint ='0000010000';type
      TOptType=(otBrowse,otAdd,otDelete,otModify,otPrint);通过!
      

  2.   

    兄弟我想把 
      1otBrowse = '0000000001';
      1otAdd ='0000000010';
      1otDelete ='0000000100';
      1otModify ='0000001000';
      1otPrint ='0000010000';
    这些常量做为TOptType的类型啊
      

  3.   

    枚举类型不支持无序类型[Error] AISMTypeUnt.pas(13): Identifier redeclared: 'otPrint'
    编译错误是因为otPrint被定义成字符串常量以后又被定义成枚举类型成员你可以这样:
    在要用到的时候用otBrowse等变量的时候用IntToBin(Ord(otBrowse))代替type
      TOptType=(otBrowse=1,otAdd=2,otDelete=4,otModify=8,otPrint=16);function IntToBin(Value:Integer; iLen:Integer = 8): String;
    var i,j,k:Integer;
        tmpstr: String;
    begin
      i:=Value;
      Result:='';
      repeat
        j:=i mod 2;
        i:=i div 2;
        tmpstr:=tmpstr+IntToStr(j);
      until i=0;
      k:=Length(tmpstr);
      for i:=0 to k-1 do
        Result:=Result+ tmpstr[k-i];
      for i:=Length(Result) to iLen-1 do
        Result:='0'+Result;
    end;但这不是好方法,楼主为啥一定要'0000000001'这样的字符串呢?
      

  4.   

    type
      TOptType=(otBrowse,otAdd,otDelete,otModify,otPrint);Var
      y: array [TOptType] of string =   ( '0000000001','0000000010','0000000100','0000001000','0000010000');