次の方法で共有


SUBSTR( ) Function

Returns a character string from the given character expression or memo field.

SUBSTR(cExpression, nStartPosition [, nCharactersReturned])

Return Values

Character

Parameters

  • cExpression
    Specifies the character expression or memo field from which the character string is returned.

  • nStartPosition
    Specifies the position in the character expression or memo field cExpression from where the character string is returned. The first character of cExpression is position 1.

    If nStartPosition is greater than the number of characters in cExpression, the empty string is returned.

  • nCharactersReturned
    Specifies the number of characters to return from cExpression. If you omit nCharactersReturned, characters are returned until the end of the character expression is reached.

Remarks

SUBSTR( ) returns a character string from a character expression or memo field, starting at a specified position in the character expression or memo field and continuing for a specified number of characters.

When using SUBSTR( ) with memo fields in a SELECT – SQL command, include the PADR( ) function in SUBSTR( ) so that empty or variable length memo fields produce consistent results when converted to character strings.

SUBSTR( ) will not return a value for a memo field when issued in the Debug window. To return a value in the Debug window, place the memo field name within ALLTRIM( ), and place ALLTRIM( ) within SUBSTR( ).

Example

STORE 'abcdefghijklm' TO mystring
CLEAR
? SUBSTR(mystring, 1, 5)  && Displays abcde
? SUBSTR(mystring, 6)  && Displays fghijklm

See Also

AT( ) | AT_C( ) | ATC( ) | ATCC( ) | ATCLINE( ) | ATLINE( ) | LEFT( ) | PADR( ) | RAT( ) | RATLINE( ) | RIGHT( ) | LEFTC( ) | RIGHTC( ) | SUBSTRC( ) | STRTRAN( ) | STUFF( )