(DataFlex) 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.
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoSb
Boolean iSuccess
Boolean iRemoveFlag
String sResult
String sTemp1
Get Create (RefClass(cComChilkatStringBuilder)) To hoSb
If (Not(IsComObjectCreated(hoSb))) Begin
Send CreateComObject of hoSb
End
// Load a file that contains this string: 0123456789ABCDEF
Get ComLoadFile Of hoSb "qa_data/txt/remove_chars.txt" "utf-8" To iSuccess
// Return "56789A" from the string.
// if removeFlag is True, the returned string is also removed from the sb.
Move True To iRemoveFlag
Get ComGetRange Of hoSb 5 6 iRemoveFlag To sResult
Showln sResult
Get ComGetAsString Of hoSb To sTemp1
Showln sTemp1
// Output is:
//
// 56789A
// 01234BCDE
End_Procedure
|