2011-03-31 75 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