Sample code for 30+ languages & platforms
DataFlex

Shorten a String in StringBuilder by N Chars

Demonstrates how to shorten a string contained in a Chilkat StringBuilder object by N chars.

Note: This example demonstrates the Shorten method which was added in Chilkat v9.5.0.87.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoSb
    String sTemp1

    Move False To iSuccess

    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

    Get ComShorten Of hoSb 3 To iSuccess

    Get ComGetAsString Of hoSb To sTemp1
    Showln sTemp1

    // Output is: 0123456789ABC


End_Procedure