繁体   English   中英

获取Delphi 2010 Comandline编译器行号

[英]Get The Delphi 2010 Comandline Compiler Line Number

有什么方法可以使Delphi 2010命令行编译器(dcc32.exe)行号传递回管道中的GUI应用程序进度栏?

或者,从以下字符串返回(行号)的好方法是:

C:\Components\Dabbler\Pipes\Demos\Demo3\TestUnit\uGlobal.pas(20) 
C:\Components\Dabbler\Pipes\Demos\Demo3\TestUnit\uGlobal.pas(339) 
C:\Components\Dabbler\Pipes\Demos\Demo3\TestUnit\uGlobal.pas(341) 
C:\Components\Dabbler\Pipes\Demos\Demo3\TestUnit\uGlobal.pas(512) 
C:\Components\Dabbler\Pipes\Demos\Demo3\TestUnit\uGlobal.pas(1024) 
C:\Components\Dabbler\Pipes\Demos\Demo3\TestUnit\uGlobal.pas(1536) 
C:\Components\Dabbler\Pipes\Demos\Demo3\TestUnit\uGlobal.pas(2048) 
C:\Components\Dabbler\Pipes\Demos\Demo3\TestUnit\uGlobal.pas(2560) 
C:\Components\Dabbler\Pipes\Demos\Demo3\TestUnit\uGlobal.pas(3072) 
C:\Components\Dabbler\Pipes\Demos\Demo3\TestUnit\uGlobal.pas(3342)  

查看JEDI JVCL安装程序。 它正是这样做的,并且它是开源的,因此您可以看到它是如何完成的。

寻找到行尾。 您在其中找到的字符应带有右括号。 向后寻找左括号。 您传递的字符是行号。

function ExtractLineNumber(const Line: string): Integer;
var
  i, len: Integer;
begin
  i := Length(Line);
  Assert(Line[i] = ')', 'unexpected line format');
  len := -1;
  while (i > 0) and (Line[i] <> '(') do begin
    Dec(i);
    Inc(len);
  end;
  Assert(i > 0, 'unexpected line format');
  Assert(len > 0, 'unexpected line format');
  Result := StrToInt(Copy(Line, i + 1, len));
end;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM