2011-03-31 44 views
1

有没有什么办法让德尔福2010年命令行编译器(dcc32.exe)行号传递回管道中的GUI应用程序进度条?获取德尔福2010年Comandline编译器行号

作为替代的是一个很好的功能,从以下字符串返回(行号):

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) 

回答

6

看那JEDI JVCL安装程序。它完全是这样,它是开源的,所以你可以看到它是如何完成的。

+0

+1检查JCL和/或JVCL源代码安装程序即可。 ;) – RRUZ 2011-03-31 03:10:57

2

寻求行结束。你在那里找到的角色应该有一个右括号。向后查找左括号。您传递的字符是行号。

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; 
+0

+1,另一种方式是使用正则表达式。 – 2011-03-31 08:42:20

+0

经过一些测试后,似乎使用正则表达式是在生成警告,提示和其他输出时消除ExtractLineNumber中的错误的方法。谢谢大家。 – Bill 2011-03-31 15:56:55