See Also: String Functions, Ltrim, Mid, Right


Left returns the left-most code points of a string up to a specified length.

Return Type



(Left( {string-value}, {length} ))


What It Does

Left returns the first (left-most) characters of {string-value} up to and including the character in Position {length}.

Move (Left(sName, 5)) To Customer.Firstname


This sample reverses the letters in a string.

Move "Joe Smith" To sName

Move (Pos (" ", sName)) To iPos

Move (Right (sName, Length (sName) - iPos) + ", " + Left (sName, iPos)) To sReversedName


This sample separates a string into words by separating character groups (words) before and after any space in the text.

Function SplitStringIntoWords String sText returns String[]

    String sWord

    String[] Words

    Integer iWordCount iSpacePos


    // Repeat as long as sText contains data

    While (sText <> "")

        // Find the first/next space

        Move (Pos (" ", sText)) To iSpacePos

        // If a space was found

        If (iSpacePos > 0) Begin

            // Take the left part

            Move (Left (sText, iSpacePos - 1)) To sWord

            // Move the remainder to the text variable

            Move (Right (sText, Length (sText) - iSpacePos)) To sText


        // If no more spaces are found

        Else Begin

            // Make word equal to the text

            Move sText To sWord

            // Empty text to stop the loop

            Move "" To sText


        Move sWord to Words[iWordCount]

        Increment iWordCount


    Function_Return Words



Procedure OnClick

    String sText

    String[] Words


    Move "Split this text into words" To sText

    Get SplitStringIntoWords sText to Words