program exam1;uses
  sysutils,
  Dialogs,
  nc_unit,
  IniFiles,
  buttons,
  controls,
  InfoBox,
  Classes,
  StrUtils,
  pp_lang in '..\..\PP_Lang\pp_lang.pas';Var bAngleShearActive,
 bPunchActive,
 bIndexToolActive,
 bHeaderLines,
 bLineInc : Boolean; iToolNumber,
 iIndex,
 iCurClamp,
 iCheck,
 iFind1,iFind2,i,k,
 iTest,
 iCurLine,
 iPos: Integer ; rRepos,rInsertionAngle,
 rCurC,rCurX,rCurY : Real; sValue,
 sTmpLine,
 sTmp,
 sCurDir,
 sIniFile,
 sNewLine,
 sLine,
 sFilename,
 sSource,
 sMain    : String;
 Lines : TStringlist; IniDatei : TIniFile; NC :TNC;
 InfoBox1      : TInfoBox ; rClamp    : Array [1..9] of Double;
 rTmpClamp : Array [1..9] of Double;Const    sVersion   = 'V0.93 vom 28.08.2003';
    sAutor     = 'A.Redeker';
    sCompany   = 'REDSoft(2003)';
    sCopyRight = 'REDSoft(2003)';
    sName      = 'EXAM Filter';
begin       sFileName := ParamStr(1);
       // IniDatei lesen
       sCurDir   := ExtractFileDir(ParamStr(0));
       sIniFile  := ChangeFileExt(ParamStr(0),'.ini');
       IniDatei := TIniFile.Create(sIniFile);     if Length(sFilename) > 0 then begin       sMain   := ChangeFileExt(sFilename,'.tap');
       iTest   := IniDatei.ReadInteger('Common','Test',0);
       if FileExists(sFilename) then begin
         Nc.ReadToolsFromFms(ChangeFileExt(sFilename,'.fms'));
         Lines := TStringList.Create;
         Lines.LoadFromFile(ParamStr(1));         iCurLine     := 0;
         bHeaderLines := True;
         bIndexToolActive := False;
         bAngleShearActive:= False;         While iCurLine < Lines.Count do begin
           sTmp := Lines[iCurLine];
           bLineInc := True;           if bHeaderLines then begin             if Copy(sTmp,1,14) = 'DEF REAL X_DIM' then begin
               Lines[iCurLine] := AnsiReplaceText(Copy(sTmp,15-5,511),',',' ');
             end;
             if Copy(sTmp,1,14) = 'DEF REAL CLAMP' then begin               //Store Clamp Positions
               rClamp[1] := NC.ReadZahl('CLAMP_1=',sTmp);
               rClamp[2] := NC.ReadZahl('CLAMP_2=',sTmp);
               rClamp[3] := NC.ReadZahl('CLAMP_3=',sTmp);               sTmp := Copy(sTmp,15-5,511);
               Lines[iCurLine] := AnsiReplaceText(sTmp,',',' ')
             end;
             if Copy(sTmp,1,14) = 'DEF REAL STROK' then begin
               iPos := Pos('SHEET_COUNT=',sTmp);
               Lines[iCurLine] := Copy(sTmp,iPos,511);
             end;             if Copy(sTmp,1,14) = 'DEF REAL FIRST' then begin
               sTmp := Copy(sTmp,15-5,511);
               Lines[iCurLine] := AnsiReplaceText(sTmp,',',' ')
             end;
             if Copy(sTmp,1,15) = 'DEF REAL PIN_NO' then Lines[iCurLine] := Copy(sTmp,15-5,511);             if sTmp = ';#FMM_CONFIG' then begin
               Lines.Delete(iCurLine);
               bLineInc := False;
             end ;             if Copy(sTmp,1,16) = 'DEF INT TABLE_NO' then Lines[iCurLine] := Copy(sTmp,9,511);
             if Copy(sTmp,1,16) = 'DEF INT STORAGE_' then Lines[iCurLine] := Copy(sTmp,9,511);             if Copy(sTmp,1,16) = 'DEF INT NEXT_STO' then begin
               Lines.Delete(iCurLine);
               bLineInc := False;
             end ;             if Copy(sTmp,1,16) = 'DEF INT EJECTOR_' then Lines[iCurLine] := Copy(sTmp,9,511);
             if Copy(sTmp,1,16) = 'DEF REAL UNLOADI' then begin
               Lines.Delete(iCurLine);
               bLineInc := False;
             end ;
             if Copy(sTmp,1,16) = 'DEF INT UNLOADIN' then begin
               Lines.Delete(iCurLine);
               bLineInc := False;
             end ;
             if Copy(sTmp,1,16) = 'DEF STRING[200] ' then begin
               Lines.Delete(iCurLine);
               bLineInc := False;
             end ;
             if Copy(sTmp,1,16) = 'DEF INT FMM_PART' then begin
               Lines.Delete(iCurLine);
               bLineInc := False;
             end ;
             if sTmp = ';#RS_CONFIG' then begin
               Lines.Delete(iCurLine);
               bLineInc := False;
             end ;             if Copy(sTmp,1,16) = 'DEF REAL BLADE_C' then Lines[iCurLine] := Copy(sTmp,10,511);             if sTmp = 'MAIN:' then bHeaderLines :=False;           end ;           iFind1 := Pos('M25',Lines[iCurLine]);
           if iFind1 > 0 then bPunchActive := True;
           iFind1 := Pos('M20',Lines[iCurLine]);
           if iFind1 > 0 then bPunchActive := False;
           if Copy(sTmp,1,9) = 'FMM_SETUP' then begin
             Lines[iCurLine] := 'RS_SETUP';
           end;
           if Copy(sTmp,1,5) = 'SETUP' then begin
             Lines[iCurLine] := Copy(sTmp,1,5);
           end;           if Copy(sTmp,1,8) = 'RS_SETUP' then begin
             Lines.Delete(iCurLine);
             bLineInc := False;
           end ;
           if Copy(sTmp,1,4) = 'SOFT' then begin
             Lines.Delete(iCurLine);
             bLineInc := False;
           end ;
           if Copy(sTmp,1,5) = 'BRISK' then begin
             Lines.Delete(iCurLine);
             bLineInc := False;
           end ;
           if Copy(sTmp,1,8) = 'ACCURACY' then begin
             Lines.Delete(iCurLine);
             bLineInc := False;
           end ;           //Single Cut Repositioning
           if Copy(sTmp,1,14) = 'SINGLE_CUT_REP' then begin
               sTmp   :=Copy(sTmp,16,255);
               sValue := '';
               iIndex := 0;
               For i := 1 to Length(sTmp) do begin
                 if sTmp[i] = ',' then begin
                   Inc(iIndex);
                   if iIndex = 6 then begin
                     Val(sValue,rRepos,iCheck);
                     rClamp[1] := rClamp[1] + rRepos ;
                     rClamp[2] := rClamp[2] + rRepos ;
                     rClamp[3] := rClamp[3] + rRepos ;
                     Break;
                   end;
                   sValue := '';
                 end else begin
                   sValue := sValue + sTmp[i];
                 end;
               end;           end ;           //Look for Tool Entry
           if (Pos('TOOL(',sTmp) > 0) or (Pos('RS_START(1)',sTmp) > 0)then begin             //Check Insertion Angle
             iToolNumber := Round(NC.ReadZahl('TOOL(',sTmp));
             if iToolNumber > 0 then begin
               rInsertionAngle := Tools[iToolNumber];
               if rInsertionAngle <> 0 then begin
                 if Copy(Lines[iCurLine-1],1,1)=';' then begin
                    Lines[iCurLine-1] := Lines[iCurLine-1] + ' Angle : ' + NC.sZahl(rInsertionAngle);
                 end;
               end;
             end;

解决方案 »

  1.   

    if bIndexToolActive then begin               //Check Previous Lines
                   if (Lines[iCurLine-2] = 'C0M20') then begin
                       Lines.Delete(iCurLine-2);
                       Dec(iCurLine);
                   end;
                   if (Lines[iCurLine-2] = 'M20') then begin
                       Lines.Delete(iCurLine-2);
                       Dec(iCurLine);
                   end;
                   Lines.Insert(iCurLine-1,'G90G53C0M20') ;
                   Inc(iCurLine);
                   Lines.Insert(iCurLine-1,'G04F0.5') ;
                   Inc(iCurLine);
                   Lines.Insert(iCurLine-1,'M69') ;
                   Inc(iCurLine);             end;             bIndexToolActive := False;
                 if (Pos('RS_START(1)',sTmp) > 0)then begin
                   bAngleShearActive:= True;
                   if Lines[iCurLine-1] = 'Y1250' then begin
                     Lines.Delete(iCurLine-1);
                     Dec(iCurLine);
                   end;
                 end;
               end;
               //Look for c-Value
               iFind1 := Pos('Z=DC(',sTmp);
               if iFind1 > 0 then begin
                 rCurC := NC.ReadZahl('Z=DC(',sTmp);
                 if rCurC <> -9999 then begin               if not bIndexToolActive then begin
                     bIndexToolActive := True;
                     Lines.Insert(iCurLine,'M68') ;
                     Inc(iCurLine);
                     Lines.Insert(iCurLine,'G04F0.5') ;
                     Inc(iCurLine);
                   end;               Lines.Insert(iCurLine,'C' + NC.sZahl(rCurC)+ 'M20') ;
                   Inc(iCurLine);               iFind2 := Pos(')',sTmp);
                   Delete(sTmp,iFind1,iFind2-iFind1+1);
                   if Length(sTmp) > 0 then begin
                     Lines[iCurLine] := sTmp;
                   end else begin
                     Lines.Delete(iCurLine);
                     bLineInc := False;
                   end;
                   //Next Line Contains a M25 ?
                   if bPunchActive = true then begin
                     iFind1 := Pos('M25',Lines[iCurLine]);
                     if iFind1 = 0 then Lines[iCurLine] := Lines[iCurLine] + 'M25';
                   end;
                 end;
               end;           //Look for Y100
               if bAngleShearActive then begin             if Lines[iCurLine] = 'Y100' then Lines[iCurLine] := 'Y140';             if Lines[iCurLine] = 'UNLOAD(1)' then begin
                   Lines.Delete(iCurLine);
                   Dec(iCurLine);
                 end;
                 if Copy(sTmp,1,10) ='CLAMP_MOVE' then begin
                   while Copy(sTmp,1,10) ='CLAMP_MOVE' do begin                 sTmpLine := Copy(sTmp,12,511);
                     sTmpLine := AnsiReplaceText(sTmpLine,')',',');                 sValue := '';
                     iCurClamp := 0 ;
                     For i := 1 To Length(sTmpLine) do begin
                        if sTmpLine[i] = ',' then begin
                          inc(iCurClamp);
                          Val(sValue,rTmpClamp[iCurClamp],iCheck);                      if rTmpClamp[iCurClamp] = 0 then rTmpClamp[iCurClamp] := rClamp[iCurClamp];                      sValue := '';
                        end else begin
                          sValue := sValue + sTmpLine[i];
                        end;
                     end;                 //Store Clamp-Values
                     For iCurClamp := 1 to 3 do begin
                       rClamp[iCurClamp] := rTmpClamp[iCurClamp];
                     end;                 sTmp := Lines[iCurLine+1];
                     if Copy(sTmp,1,10) ='CLAMP_MOVE' then begin
                       Lines.Delete(iCurLine);
                     end;
                   end;
                   sTmpLine :=  '';
                   For i := 1 to 3 do begin
                     sTmpLine := sTmpLine + NC.sZahl(rTmpClamp[i]);
                     if i<3 then sTmpLine := sTmpLine + ', ';
                   end;               sTmpLine := 'PCS(' + Trim(sTmpLine) + ')' ;
                   Lines[iCurLine] := sTmpLine ;
                 end;
               end;
               if bLineInc then Inc(iCurLine);         end;         if iTest = 1 then begin
               Lines.SaveToFile(sMain);
             end else
               Lines.SaveToFile(ParamStr(1));       end else begin         ShowMessage('Datei ' + sSource + ' nicht gefunden!');       end;     end else begin       ShowMessage('Keinen Dateinamen als Parameter angegeben');       InfoBox1:= TInfoBox.Create(Nil) ;       InfoBox1.ProductName := sName ;
           InfoBox1.Version     := sVersion;
           InfoBox1.CopyRight   := sCopyRight;
           InfoBox1.IniDatei    := ExtractFileName(sIniFile);
           InfoBox1.Comments    := 'Filter f黵 JetCam Code ';       InfoBox1.Execute;
           InfoBox1.Destroy;
         end;end.pp_lang.pas大家有知道是什么文件吗?
      

  2.   

    这是一个文本过滤程序,很简单,但必须要pp_lang.pas才能编译,我怀颖在有些版本的delphi中含此文件,大家能不能帮看看
      

  3.   

    长est!!!! 调试时有什么错误提示啊?
      

  4.   

    把“..\..\PP_Lang\pp_lang.pas”换成一个绝对路径吧。
    比如:D:\Pas\Test.Pas.