Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PowerBuilder) Implement Preprocessor #include with StringBuilderDemonstrates how to implement #include with a Chilkat StringBuilder.
integer li_rc oleobject loo_SbSrc string ls_FilePath oleobject loo_SbIncludeFile // First build a string that has a preprocessor include loo_SbSrc = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbSrc.ConnectToNewObject("Chilkat.StringBuilder") if li_rc < 0 then destroy loo_SbSrc MessageBox("Error","Connecting to COM object failed") return end if loo_SbSrc.Append("1~r~n2~r~n3~r~n") loo_SbSrc.Append("#include <qa_data/txt/helloWorld.txt>~r~n") loo_SbSrc.Append("4~r~n5~r~n") Write-Debug loo_SbSrc.GetAsString() // sbSrc contains: // 1 // 2 // 3 // #include <qa_data/txt/helloWorld.txt> // 4 // 5 // The qa_data/txt/helloWorld.txt file contains "Hello World!" ls_FilePath = loo_SbSrc.GetAfterBetween("#include","<",">") if loo_SbSrc.LastMethodSuccess <> 1 then Write-Debug "No #include's found." destroy loo_SbSrc return end if Write-Debug "filePath: " + ls_FilePath // Load the contents of the filePath loo_SbIncludeFile = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbIncludeFile.ConnectToNewObject("Chilkat.StringBuilder") loo_SbIncludeFile.LoadFile(ls_FilePath,"utf-8") // Replace the first occurrence of #include <...> line with the contents of the include file. loo_SbSrc.ReplaceAllBetween("#include",">",loo_SbIncludeFile.GetAsString(),1) Write-Debug loo_SbSrc.GetAsString() // sbSrce now contains: // 1 // 2 // 3 // Hello World! // 4 // 5 destroy loo_SbSrc destroy loo_SbIncludeFile |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.