AutoIt
AutoIt
StringBuilder SetNth
Demonstrates the SetNth method.Chilkat AutoIt Downloads
; The SetNth method is handy for setting a part of a delimited string.
; For example:
$oSb = ObjCreate("Chilkat.StringBuilder")
$oSb.Append("red,blue,""green,purple"",,yellow")
Local $sDelimiterChar = ","
Local $bExceptDoubleQuoted = True
Local $bExceptEscaped = True
$oSb.SetNth(2,"magenta",$sDelimiterChar,$bExceptDoubleQuoted,$bExceptEscaped)
; Prints "red,blue,magenta,,yellow"
ConsoleWrite($oSb.GetAsString() & @CRLF)
$oSb.SetNth(3,"orange",$sDelimiterChar,$bExceptDoubleQuoted,$bExceptEscaped)
; Prints "red,blue,magenta,orange,yellow"
ConsoleWrite($oSb.GetAsString() & @CRLF)
; What happens if we start with an empty string?
$oSb.Clear
$oSb.SetNth(2,"apple",$sDelimiterChar,$bExceptDoubleQuoted,$bExceptEscaped)
; Prints ",,apple"
ConsoleWrite($oSb.GetAsString() & @CRLF)
$oSb.SetNth(0,"orange",$sDelimiterChar,$bExceptDoubleQuoted,$bExceptEscaped)
; Prints "orange,,apple"
ConsoleWrite($oSb.GetAsString() & @CRLF)
$oSb.SetNth(1,"banana",$sDelimiterChar,$bExceptDoubleQuoted,$bExceptEscaped)
; Prints "orange,banana,apple"
ConsoleWrite($oSb.GetAsString() & @CRLF)