例如:文本文件的某行如下
楼盘名称xxxx建设发展有限公司楼盘编号000001
        .............数据库表table1有2个字段Lpmc,Lpbh.
将上句的第5-16位"xxxx建设发展有限公司"读入LPMC,第21-26位"000001"读入LPBH后
table1数据为:
Lpmc                 Lpbh
xxxx建设发展有限公司  000001
        .............Pascal语言如何写?

解决方案 »

  1.   

    procedure TForm1.Button1Click(Sender: TObject);//直接位数不合理,公司名称可能长短不一
    //如果 楼盘名称和 楼盘编号都有得花
    VAR
       txt :textfile;
       iS1,iS2:integer;
       sTmp,sLpmc,sLpbh:string;
    begin  if not fileexists('楼盘.txt') then
      begin
        showmessage('error');
        exit;
      end;
       assignfile(txt,'楼盘.txt');
      reset(txt);
      while not eof(txt) do
      begin
        readln(txt,sTmp);
        iS1 := pos('楼盘名称',sTmp);
        iS2 :=pos('楼盘编号',sTmp);
        if (iS1>0) and(iS2>0) then
        begin
          sLpmc := copy(sTmp,9,is2-8);
          sLpbh := copy(sTmp,iS2,255);
          //入库
        end;
      end;
    end;
    请大家去 http://www.new7wonders.com/c/voting.php 投长城一票