beautypg.com

Leftstr, Tstr, righ – Visara Master Console Center Scripting Guide User Manual

Page 143

background image

Chapter 5 Script Commands

Scripting Guide

143

LEFTSTR

Syntax:

LEFTSTR( $String, %Count) ==> $SubStr

Description:

Returns the leftmost specified number of characters of a string expression.

Action:

A substring is extracted from a string expression. The substring begins

with the first character in the string expression.

Parameters:

$String. String expression. The character string from which to extract

characters.
%Count. Numeric expression. The number of characters to extract. If
Count is negative or zero, LEFTSTR() returns an empty string “”. If Count

is larger than the length of String, LEFTSTR() returns the entire String.

Returns:

String value. The leftmost Count characters of String as a character string.

Notes:

Example:

$Msg := “This is a test.”
$Var := LEFTSTR( $Msg, 4)
// $Var will contain the string ‘This’

$Var := LEFTSTR( “****” + $Msg[ 1] + $Msg[ 2] + “****”, 20)
// $Var will contain a string starting with 4 asterisks, and
// containing the first 16 characters of the combination of
// strings $Msg[1] and $Msg[2]. If there are less than 16
// characters in those variables, $Var will also contain up to
// 4 asterisks at the end.

See Also:

ATSTR, FINDSTR, RIGHTSTR, REPSTR, STR, SUBSTR