字符串A是一纯数字字符串,其长度超过int64,如何定义该字符串的自增函数,自增量为1.

解决方案 »

  1.   

    定义一个动态数组来存储:
    const initLen=10;
    a:array of char;
    SetLength(a,initLen);
    a[1]:='1'
    ……
    ……
    ……
    SetLength(a,initLen+N);//N可以自己去设置
      

  2.   

    to scfanxzq:
    这是动态字符数组,不是我需要的吧。
    需要实现的是类似自增字段(autoinc)的功能,但是因为该数字比较大,所以用字符串储存。
    如:
    90000000000000000000001
    90000000000000000000002
    90000000000000000000003
    90000000000000000000004
    90000000000000000000005
    90000000000000000000006
    ...................
    这样的序列。
      

  3.   

    这样可以吗?type
      Tmyint64=record
        hi:int64;
        lo:int64;
      end;
    var
      myint64:Tmyint64;procedure myint64inc(val:Tmyint64);
    begin
      if val.lo=high(int64) then
        inc(val.hi)
      else
        inc(val.lo);
    end;
    procedure TForm1.Button1Click(Sender: TObject);
    var
      str:string;
    begin
      myint64.lo:=1234567;//测试
      myint64.hi:=4567788;
      myint64inc(myint64);
      str:=inttostr(myint64.hi)+inttostr(myint64.lo);
      showmessage(str);
    end;
      

  4.   

    type
      TIntString = array [0..10] of Char;procedure IncInt(var V: TIntString);
    var
      I: ShortInt;
    begin
      I := High(TIntString);
      while not (V[I] in ['0'..'9']) do Dec(I);  while V[I] = '9' do
      begin
        V[I] := '0';
        Dec(I);
        if I < 0 then break;
      end;
      if I >= 0 then
        Inc(V[I]);
    end;procedure TForm1.Button1Click(Sender: TObject);  procedure DoIt(var V: TIntString);
      begin
        IncInt(V);
        Memo1.Lines.Add(V);
      end;var
      V: TIntString;
    begin
      V := '9000000001';
      DoIt(V);
      V := '9000000008';
      DoIt(V);
      V := '9999999998';
      DoIt(V);
      DoIt(V);
      DoIt(V);
    end;
      

  5.   

    根据需要将TIntString定义成需要的长度,
    自己再写DecInt函数。