From a7ea084059dbeab56243b246573564e186c0fbdc Mon Sep 17 00:00:00 2001 From: mattias Date: Fri, 28 Mar 2008 09:44:14 +0000 Subject: [PATCH] codetools: h2p example: writing output unit to disk git-svn-id: trunk@14673 - --- components/codetools/examples/h2pastest.lpr | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/components/codetools/examples/h2pastest.lpr b/components/codetools/examples/h2pastest.lpr index c68407fe30..06deffc60c 100644 --- a/components/codetools/examples/h2pastest.lpr +++ b/components/codetools/examples/h2pastest.lpr @@ -56,11 +56,12 @@ begin if CCode=nil then raise Exception.Create('loading failed '+Filename); // Step 2: create the output file - OutputFilename:='h2pasoutput.pas'; + OutputFilename:=CleanAndExpandFilename(AppendPathDelim(GetCurrentDir)+'h2pasoutput.pas'); PasCode:=CodeToolBoss.CreateFile(OutputFilename); if PasCode=nil then raise Exception.Create('creating failed '+OutputFilename); + // Step3: convert Tool:=TH2PasTool.Create; Tool.SourceName:=ExtractFileNameOnly(PasCode.Filename); Tool.Convert(CCode,PasCode); @@ -71,6 +72,12 @@ begin writeln('============================================='); writeln(PasCode.Source); Tool.Free; + + // Step 4: write unit + if PasCode.Save then + writeln('Wrote ',PasCode.Filename) + else + writeln('Failed writing ',PasCode.Filename); except on E: ECCodeParserException do begin CCodeTool:=ECCodeParserException(E).Sender;