Appendix > Pre-Defined Functions

String Functions

"True string functions" are those that return string values. Such functions can be specified with or without a trailing $ (i.e., CHR(X) or CHR$(X); we use the trailing $ below to emphasize that the function acts like a string expression.) Also included here are functions that that return numeric values (and thus are really numeric functions) but whose purpose is closely tied to string handling, such as LEN().

Function

Description

ASC(a$)

Returns ASCII value (in decimal) of first character of a$ (numeric function).

CHR$(x)

Returns the ASCII character corresponding to the value x.

EDIT(a$,flags)

Returns a modified version of the string a$, based on option bits set in flags.

FILL(a$,n)

Returns a string consisting of the string a$ repeated until it reaches n bytes long. Requires COMPIL switch /X:1 or higher.

INSTR$(spos, source$, pattern$, {flags})

Returns position of first occurrence of pattern$ after position spos (starting at 1) in source$, or 0 if not found. With flags: pattern$ is interpreted as a "regular expression", and flags may be used to specify options relating to regular expression evaluation. See INSTR() for more information and details.

LCS$(a$)

Returns string a$ folded to lower case.

LEFT$(a$,x)

Returns leftmost x characters of string a$. Equivalent to a$[1,x].

LEN(a$)

Returns length of string a$. (Numeric function).

MID$(a$,start,length)

Returns substring of a$, starting in position start and extending length characters (or until end). Equivalent to substring syntax a$[start;length].

ODTIM(date,time{,flags})

Returns formatted string representation of specified date and/or time according to flags. See ODTIM and ODTIM.SBR in the A-Shell XCALL Reference.

PAD$(a$,x)

Returns string a$ truncated, or padded with trailing blanks as necessary to be exactly x characters long. (A-Shell extension)  

RIGHT$(a$,x)

Returns the rightmost x characters of string a$. Equivalent to a$[-x,-1].

RTRIM(a$)

Returns string a$ with trailing spaces removed. (A-Shell extension.)

SPACE$(x)

Returns a string of x spaces. Also see FILL(X,N).

STRIP(a$)

Same as RTRIM(a$). (Plus extension.)

STR$(x)

Returns the string decimal representation of the value x, with no leading or trailing blanks.

UCS$(a$)

Returns string a$ folded to upper case.