See Also: String Functions, Left, Mid, Pos, Rtrim


Right returns the right-most code points of a string up to a specified length.

Return Type



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


What It Does

The Right function returns the trailing (right-most) code points of {string-value} up to and including the character in Position {length} as counted backwards from the end of the string.

String sName

Move "John Smith" to sName

Move (Right(sName, 5)) To Customer.LastName

In this example, the last 5 characters of the value in the variable sName ("Smith") would be moved to the database field Customer.LastName.


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