inc(foundstr,length(foundstr));foundstr在执行这条语句之前为"want to" 在执行之后就是"",这是为什么?inc()对它进行了什么操作?inc()不是对参数进行加值的操作吗!

解决方案 »

  1.   

    foundstr must be a variable of an ordinal type 
    不能是string
      

  2.   

    同志们那是一条正确的语句.完成的程序如下:  retval:=findfirst(dlbdirectories.directory + '\*.txt',faAnyFile,searchrec);
      try
         while retval=0 do
            begin
               fname:=searchrec.Name;
              memmapfile:=tmemmapfile.create(fname,fmopenread,0,true);
               try
                  findstring:=edtsearchstring.text;
                  wordcount:=0;
                  foundstr:=strpos(pchar(memmapfile.data),pchar(findstring));
                  if foundstr<>nil then
                  begin
                      repeat
                        inc(wordcount);
                        showmessage('start foundstr:' + foundstr);
                        inc(foundstr,length(foundstr));
                        showmessage('end foundstr:' + foundstr);
                        foundstr:=strpos(pchar(foundstr),pchar(findstring));
                      until foundstr=nil;
                      lbfilesfound.items.add(searchrec.name+' . '+inttostrwordcount));
                  end;
                  retval:=findnext(searchrec);