Updated June 2021; see History
"True string functions" are those that return string values. Such functions can usually 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 return numeric values (and thus are really numeric functions) but whose purpose is closely tied to string handling, such as LEN(). Note that the a$ and x are used below to indicate string and numeric arguments, respectively, and that in all cases those arguments could be either variables or expressions.
Function |
Description |
ASC(a$) |
Returns numeric value of first character of a$. |
AUTOCAP$(a$) |
"Intelligently" capitalizes the specified string. Note that the A-Shell implementation of this is rather minimal; users in need of more "intelligent" capitalization should refer to XFOLD.SBR. |
CHR$(x) |
Returns the OEM or Latin1 character—depending on the current character set—corresponding to the value x. |
Returns a modified version of the string a$, based on option bits set in flags. | |
Returns a string consisting of the string a$ repeated until it reaches n bytes long. Requires COMPIL switch /X:1 or higher. | |
Returns position of first occurrence of pattern$ in source. | |
LCS$(a$) |
Returns string a$ folded to lower case. |
LEFT$(a$,x) |
Returns leftmost x characters of string a$. Equivalent to a$[1,x]. |
Returns length of string a$. | |
LSTRIP(a$) |
Strips leading blanks from the specified string expression. Syntax: LSTRIP(a$) or LSTRIP$(a$). |
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]. |
Treats expression as numeric. | |
Outputs the specified date and/or time according to the formatting flags. | |
Returns string a$ truncated, or padded with trailing blanks as necessary to be exactly x characters long. | |
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. |
SPACE$(x) |
Returns a string of x spaces. Also see FILL(). |
Treats the expression argument as a string. | |
STRIP$(a$) |
Same as RTRIM$(a$). |
Convert a numeric value or expression to string. | |
TRIM(a$) |
TRIM(a$) or TRIM$(a$) removes the leading and trailing blanks from a string; equivalent to the combination of STRIP$(a$) and LSTRIP$(a$). Besides offering the advantage of functional syntax, as a built-in function, TRIM$() is more efficient than the equivalent XCALL TRIM, although the latter offers the option to remove characters besides blanks. |
UCS$(a$) |
Returns string a$ folded to upper case. |
Returns the decimal value of a string. | |
Extended version of VAL. |
History
2022 March, A-Shell 6.5.1713, compiler edit 977: Add TRIM.
2022 March, A-Shell 6.5.1712, compiler edit 971: Add LSTRIP.
2021 June, A-Shell 6.5.1704, compiler edit 947: all standard string functions now support the optional $ suffix on the name (e.g. STR(x) or STR$(x).) The following functions did not previously support the optional $ suffix: AUTOCAP$(a$), LCS$(a$), ODTIM$(), RTRIM$(a$), UCS$(a$)