Show TOC

strSub FunctionLocate this document in the navigation structure

Use

Purpose

Returns a substring from a given string.

Syntax

string  strSub  (in string  string,
in int     position,
in int     length)
            

Parameters

string

Expression evaluating to a string.

position

Starting position of the substring within string [1..n].

length

Number of characters to put into the substring starting at position.

Description

When you can specify the starting position position and length length, strSub returns the length length, starting at the position you request.

  • If you specify a length of 0, strSub returns all characters from the starting position to the end of the string.

  • If length is greater than the number of characters in the source string, strSub uses all characters up to the end of the string.

Return Value

Returns a substring (a copy) of the given string.

Example
`name = "Walt Whitman"`
The last name of `name` is
  `if (0 != (j = strstr (name, " ")))`
    `strSub (name, j + 1, 0)`
  `else`   
    undefined.  
`end`