(PureBasic) Get a Substring by Char Index and Length
Demonstrates how to use the GetRange method to get a substring by index and length.
Note: This example demonstrates the GetRange method which was added in Chilkat v9.5.0.87.
IncludeFile "CkStringBuilder.pb"
Procedure ChilkatExample()
sb.i = CkStringBuilder::ckCreate()
If sb.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; Load a file that contains this string: 0123456789ABCDEF
success.i = CkStringBuilder::ckLoadFile(sb,"qa_data/txt/remove_chars.txt","utf-8")
; Return "56789A" from the string.
; if removeFlag is 1, the returned string is also removed from the sb.
removeFlag.i = 1
result.s = CkStringBuilder::ckGetRange(sb,5,6,removeFlag)
Debug result
Debug CkStringBuilder::ckGetAsString(sb)
; Output is:
;
; 56789A
; 01234BCDE
CkStringBuilder::ckDispose(sb)
ProcedureReturn
EndProcedure
|