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) StringBuilder SetNthDemonstrates the SetNth method.
integer li_rc oleobject loo_Sb string ls_DelimiterChar integer li_ExceptDoubleQuoted integer li_ExceptEscaped // The SetNth method is handy for setting a part of a delimited string. // For example: loo_Sb = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_Sb.ConnectToNewObject("Chilkat.StringBuilder") if li_rc < 0 then destroy loo_Sb MessageBox("Error","Connecting to COM object failed") return end if loo_Sb.Append("red,blue,~"green,purple~",,yellow") ls_DelimiterChar = "," li_ExceptDoubleQuoted = 1 li_ExceptEscaped = 1 loo_Sb.SetNth(2,"magenta",ls_DelimiterChar,li_ExceptDoubleQuoted,li_ExceptEscaped) // Prints "red,blue,magenta,,yellow" Write-Debug loo_Sb.GetAsString() loo_Sb.SetNth(3,"orange",ls_DelimiterChar,li_ExceptDoubleQuoted,li_ExceptEscaped) // Prints "red,blue,magenta,orange,yellow" Write-Debug loo_Sb.GetAsString() // What happens if we start with an empty string? loo_Sb.Clear() loo_Sb.SetNth(2,"apple",ls_DelimiterChar,li_ExceptDoubleQuoted,li_ExceptEscaped) // Prints ",,apple" Write-Debug loo_Sb.GetAsString() loo_Sb.SetNth(0,"orange",ls_DelimiterChar,li_ExceptDoubleQuoted,li_ExceptEscaped) // Prints "orange,,apple" Write-Debug loo_Sb.GetAsString() loo_Sb.SetNth(1,"banana",ls_DelimiterChar,li_ExceptDoubleQuoted,li_ExceptEscaped) // Prints "orange,banana,apple" Write-Debug loo_Sb.GetAsString() destroy loo_Sb |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.