The following built-in functions operate upon strings (ie, the values of variables, return strings from other functions, literal strings, etc) which may contain any sort of data.

ABBREV Tests if a substring is an abbreviation of another string.
CENTER Formats a string to fit centered within a given number of characters.
CENTRE Same as CENTER.
CHANGESTR Exchanges any occurence of one substring with another substring.
COMPARE Compares two strings for inequality, and returns the position where they differ.
COPIES Concatenates a string a specified number of times.
COUNTSTR Counts how many occurences of a substring are within another string.
DELSTR Deletes one or more characters from a string.
EXPAND Replaces tab characters with spaces, or vice versa.
INSERT Inserts a substring into another string.
LASTPOS Finds the last occurrence of a substring within another string.
LEFT Excerpts characters from the left-hand side of a string.
LENGTH Counts the number of characters in a string.
OVERLAY Overlays one string into another string.
POS Finds the first occurrence of a substring within another string.
REVERSE Reverses the order of characters in a string.
RIGHT Excerpts characters from the right-hand side of a string.
STRIP Removes reading and trailing spaces (or other characters) from a string.
SUBSTR Excerpts a substring from another string.
TRANSLATE Translates characters in a string to other characters, or makes a string uppercase.
VERIFY Tests if any characters of one string also occur in another string.
XRANGE Creates a range of characters between a given start character and end character.


ABBREV

Tests if one string is an abbreviation of another string. An abbreviation is a substring that starts at the beginning of a string. For example, 'auto' could be an abbreviation for 'automobile'.

Synopsis
result = ABBREV(string, abbreviation, length)

Args

string is the string (for which abbreviation may be an abbreviation).

abbreviation is a possible abbreviation of string.

length is the minimum length that abbreviation must be in order to be considered as an abbreviation. If length is omitted, there is no restriction upon abbreviation's minimum length (and therefore an empty string would be considered an abbreviation for any other string).

Returns

1 if abbreviation is an abbreviation of string, or 0 if not.

Notes

ABBREV() is case sensitive, and leading/trailing spaces are not stripped off before the two strings are compared.

Examples

Example use
Return value
ABBREV('Foobar', 'Foo')
1
ABBREV('Foobar', 'Foo', 4)
0 /* 'Foo' isn't at least 4 chars */
ABBREV('Foobar', 'foo')
0 /* Different case - 'F' versus 'f' */

See also

POS, WORDPOS, VERIFY


CENTER

Returns a string formatted to fit centered within a certain number of characters. If necessary, the string's size is decreased to fit into that many characters, or pad characters are used to fill out the new string with the original string centered within the new string.

Synopsis
formatted = CENTER(string, length, padchar)

Args

string is the original string (to format).

length is the desired length of the final string. If length is less than the size of the original string, then characters will be deleted from the front and end of the string in order to fit the desired length. If length is greater than the size of the original string, then the original string will be centered within the new string and padchar characters will be used to fill out the new string to the desired length. length must not be negative, nor have a fractional component -- it must be a positive whole number.

padchar is the character to use for padding (if the original string is not already >= the desired length). If padchar is omitted, the default is a space character.

Returns

A copy of the original string extended to the desired length, with the original string centered within the new string, and padchars filling out the new string.

Notes

The original string is not altered. Only the returned value from CENTER is formatted.

If length is an odd number, any extra padchar is placed on the right-hand side of the centered, original string.

Examples

Example use
Return value
CENTER('Foobar',10)
'  Foobar  '
CENTER('Foobar', 11)
'  Foobar   '
CENTER('Foobar', 3)
'oob'
CENTER('Foobar', 4)
'ooba'
CENTER('Foobar', 10, '*')
'**Foobar**'

See also

JUSTIFY, EXPAND, SPACE, FORMAT, TRANSLATE, LEFT, RIGHT


CHANGESTR

Exchanges any occurence of one substring (within a given string) with another substring.

Synopsis
newstring = CHANGESTR(searchfor, string, exchange)

Args

string is the original string (to exchange substrings within).

searchfor is which substring to search for (within string. If searchfor is an empty string, then no exchange is performed, and the original string is returned.

exchange is the substring to insert in place of searchfor, wherever searchfor occurs within string. If exchange is an empty string, then each occurence of searchfor is deleted without being replaced by anything.

Returns

A copy of the original string with all occurences of searchfor replaced with exchange.

Notes

The original string is not altered.

Examples

Example use
Return value
CHANGESTR('a', 'fred', 'c')
'fred'
CHANGESTR('', '', 'new string')
''
CHANGESTR('a', 'abcdef', 'x')
'xbcdef'
CHANGESTR('0', '0', '1')
'1'
CHANGESTR('a', 'def', 'xyz')
'def'
CHANGESTR('a', '', 'x')
''
CHANGESTR('', 'def', 'xyz')
'def'
CHANGESTR('abc', 'abcdef', 'xyz')
'xyzdef'
CHANGESTR('abcdefg', 'abcdef', 'xyz')
'abcdef'
CHANGESTR('abc', 'abcdefabccdabcd', 'z')
'zdefzcdzd'

See also

TRANSLATE


COMPARE

Compares two strings for inequality, and returns the position where they differ.

Synopsis
result = COMPARE(string1, string2, padchar)

Args

string1 and string2 is the two strings to be compared.

If one of the strings is shorter than the other, padchar is the character used to pad out the shorter string to the same length as the longer string. If padchar is omitted, then by default, the shorter string is padded with extra spaces.

Returns

0 if both strings are equal. If not equal, then the first position where the two strings are different is returned (where 1 is the first character in the strings).

Notes

COMPARE() is case-sensitive, so 'BLORT' does not equal 'blort'. Use TRANSLATE() to upper-case the strings prior to COMPARE(), if desired.

Leading and trailing spaces do matter, so ' blort ' does not equal 'blort'. Use STRIP() to removed leading/trailing space prior to COMPARE(), if desired.

Examples

Example use
Return value
COMPARE('FooBar', 'Foobar')
4
COMPARE('Foobar', 'Foobar')
0
COMPARE('Foobarrr', 'Fooba')
6
COMPARE('Foobarrr', 'Fooba', 'r')
0

See also

POS, WORDPOS, ABBREV, COUNTSTR, LASTPOS, VERIFY


COPIES
Creates a new string that is another string concatenated (ie, appended) a specified number of times.

Synopsis
newstring = COPIES(string, total)

Args

string is the original string (to append). If string is an empty string, then the resulting newstring is also an empty string.

total is a count of how many times to append string. total cannot be negative, nor have a fractional component -- it must be a positive whole number. If total is 0, an empty string is created.

Returns

The new string comprised of total instances of string appended.

Examples

Example use
Return value
COPIES('Foo', 3)
'FooFooFoo'
COPIES('*', 16)
'****************'
COPIES('Bar ', 2)
'Bar Bar '
COPIES('', 10000)
''


COUNTSTR

Counts how many occurences of a substring are within another string.

Synopsis
howmany = COUNTSTR(searchfor, string)

Args

string is the original string (to search for searchfor within).

searchfor is which substring to search for (within string. If searchfor is an empty string, then 0 is returned to indicate no occurrences of searchfor within string.

Returns

A count of how many occurrences of searchfor appear within string.

Examples

Example use
Return value
COUNTSTR('', '')
0
COUNTSTR('a', 'abcdef')
1
COUNTSTR(0, 0)
1
COUNTSTR('a', 'def')
0
COUNTSTR('a', '')
0
COUNTSTR('', 'def')
0
COUNTSTR('abc', 'abcdef')
1
COUNTSTR('abcdefg', 'abcdef')
0
COUNTSTR('abc', 'abcdefabccdabcd')
3
COUNTSTR('aaa', 'aaaaaa')
2


DELSTR

Removes one or more characters from a string.

Synopsis
newstring = DELSTR(string, start, length)

Args

string is the string to remove characters from.

start is which character number to start removing from, where 1 would be to start removing at the first character in the string. If there are less characters in the string than start, then no characters are removed.

length is the desired number of characters to remove (within string), starting at (ie, including) the start character. If length is omitted, then the default is to remove all character from the start character to the end of the string. length cannot be negative, nor have a fractional component -- it must be a positive whole number.

Returns

A copy of the original string without the removed characters.

Notes

It is not an error if start or length (or a combination of them) refers to more characters than string actually contains.

The original string is not altered. Only the returned value from DELSTR has characters removed.

Examples

Example use
Return value
DELSTR('Foobar', 3)
'Foo'
DELSTR('Foobar', 3, 2)
'Foor'
DELSTR('Foobar', 3, 4)
'Foo'
DELSTR('Foobar', 7)
'Foobar'

See also

DELWORD, OVERLAY, LEFT


EXPAND

Replaces tab characters with spaces, or vice versa.

Synopsis
newstring = EXPAND(string, options, tabwidth1, tabwidth2, ...)

Args

string is the string to replace characters within.

options is the desired operation. It is one of the following:

Option
Meaning
'S' Replace each tab character with an appropriate number of spaces based upon the tabwidth args.
'T' Replace space characters with a tab character based upon the tabwidth args.

If omitted, options defaults to 'S'.

tabwidth1 is the desired width of the first tab stop. For example, a value of '8' would put the first tab stop at the eighth character. If omitted, tabwidth1 defaults to 8. There may be more tabwidth arguments supplied. For example, if tabwidth2 is supplied, then this sets the width of the second tab stop. For example, a value of '8' would effectively put the second tab stop at the sixteenth character. If there are more spaces/tabs to be replaced than there are tabwidths specified, then the value of the last tabwidth is used for all subsequent replacements.

Returns

A copy of the original string with the space/tab characters replaced.

Notes

The first character in string is presumed to be at a tabstop.

The original string is not altered. Only the returned value from EXPAND has characters replaced.

Some interpreters do not support this function.

Examples

Example use
Return value
EXPAND('   Foo   bar', 'T', 3)
'09'X || 'Foo' || '09'X || 'bar'
EXPAND('   Foo bar', 'T')
'   Foo bar'
EXPAND(' Foo   bar', 'T', 3)
' Foo' || '09'X || ' bar'
EXPAND('        Foo   bar', 'T')
'09'X || 'Foo   bar'
EXPAND('       Foo   bar ', 'T', 3, 3, 6)
'0909'X || ' Foo' || '09'X || ' bar '

See also

JUSTIFY, CENTER, SPACE, FORMAT, TRANSLATE


INSERT

Inserts a substring into another string.

Synopsis
newstring = INSERT(insert, string, position, length, padchar)

Args

insert is the substring to be inserted (into string).

string is the string into which insert is inserted.

position is the desired character position (within string) after which to insert insert. A position of 0 would cause insert to be inserted before the first character in string (ie, at the very start). A position of 1 would cause insert to be inserted after the first character in string (ie, at the very start). If position is greater than the number of characters in string, then insert will be inserted after the last character of string. If position is omitted, then it defaults to 0.

length is the desired length for insert. If insert is larger, then characters will be deleted from the end of the string in order to fit the desired length. If insert is smaller, then it is padded out with padchar characters at the end to fit the desired length. length must not be negative, nor have a fractional component -- it must be a positive whole number. If length is omitted, then no truncation nor padding is performed upon insert.

padchar is the character to use for padding (if the insert is not already >= length). If padchar is omitted, the default is a space character.

Returns

A copy of the original string with insert inserted into it.

Notes

The original string is not altered. Only the returned value from INSERT has the inserted substring.

Examples

Example use
Return value
INSERT('first', 'SECOND')
'SECONDfirst'
INSERT('first', 'SECOND', 3)
'fiSECONDrst'
INSERT('first', 'SECOND', 3, 10)
'fiSECOND rst'
INSERT('first', 'SECOND', 3, 10, '*')
'fiSECOND****rst'
INSERT('first', 'SECOND', 3, 4)
'fiSECOrst'
INSERT('first', 'SECOND', 8)
'first SECOND'

See also

JUSTIFY, SPACE, COPIES, CENTER, OVERLAY


LASTPOS

Finds the last occurrence of a substring within another string.

Synopsis
where = LASTPOS(searchfor, string, start)

Args

searchfor is which substring to search for (within string. If searchfor is an empty string, then 0 is returned to indicate no occurrences of searchfor within string.

string is the original string (to search for searchfor within).

start is which character position to start the backward search from, where 1 would be to start searching backwards at the first character in string. If omitted, the default is to start searching from the last character. start must not be negative, nor have a fractional component -- it must be a positive whole number.

Returns

If searchfor is found, then LASTPOS() returns the character position where the last occurrence of searchfor occurs within string (where 1 is the first character within string). If searchfor is not found, then LASTPOS() returns 0.

Examples

Example use
Return value
LASTPOS('be', 'to be or not to be')
17
LASTPOS('to', 'to be or not to be', 10)
3
LASTPOS('is', 'to be or not to be')
0

See also

WORDPOS, POS, COUNTSTR, VERIFY


LEFT

Excerpts one or more characters from the left-hand side of a string.

Synopsis
excerpt = LEFT(string, length, padchar)

Args

string is the original string (from which to excerpt characters).

length is the number of characters to be excerpted. If length is 0, no characters are excerpted. If length is greater than the number of characters in string, then the excerpt is padded out with padchar characters to the desired length.

padchar is the character to use for padding (if the original string is not >= length). If padchar is omitted, the default is a space character.

Returns

A string containing the excerpted characters.

Notes

The original string is not altered.

Examples

Example use
Return value
LEFT('Foo bar', 5)
'Foo b'
LEFT('Foo bar', 3)
'Foo'
LEFT('Foo bar', 10)
'Foo bar   '
LEFT('Foo bar', 10, '*')
'Foo bar***'

See also

SUBSTR, RIGHT, SUBWORD


LENGTH

Counts the number of characters in a string.

Synopsis
howmany = LENGTH(string)

Args

string is the string (whose length is to be calculated).

Returns

A count of how many characters are in the string.

Notes

Leading and trailing spaces are counted. You may wish to use STRIP first to trim those spaces.

Examples

Example use
Return value
LENGTH('')
0
LENGTH('Foo')
3
LENGTH('Foo bar')
7
LENGTH(' foo bar ')
10


OVERLAY

Overlays a substring into another string. OVERLAY() differs from INSERT() in that OVERLAY() overwrites characters in the string.

Synopsis
newstring = OVERLAY(overlay, string, position, length, padchar)

Args

overlay is the substring to be inserted (into string).

string is the string into which overlay is overlaid.

position is the desired character position (within string) at which to overlay overlay. A position of 1 would cause overlay to be overlaid at the first character in string (ie, at the very start). If position is greater than the number of characters in string, then the new string will be padded out with padchar characters and then overlay will be inserted after those pad characters. If position is omitted, then it defaults to 1.

length is the desired length for overlay. If overlay is larger, then characters will be deleted from the end in order to fit the desired length. If overlay is smaller, then it is padded out with padchar characters at the end to fit the desired length. length must not be negative, nor have a fractional component -- it must be a positive whole number. If length is omitted, then no truncation nor padding is performed upon overlay.

padchar is the character to use for padding (if the overlay is not already >= length). If padchar is omitted, the default is a space character.

Returns

A copy of the original string with overlay overlaid in it.

Notes

The original string is not altered. Only the returned value from OVERLAY has the overlaid substring.

Examples

Example use
Return value
OVERLAY('NEW', 'old-value')
'NEW-value'
OVERLAY('NEW', 'old-value', 4)
'oldNEWlue'
OVERLAY('NEW', 'old-value', 4, 5)
'oldNEW  e'
OVERLAY('NEW', 'old-value', 4, 5, ‘*’)
'oldNEW**e'
OVERLAY('NEW', 'old-value', 4, 2)
'oldNEalue'
OVERLAY('NEW', 'old-value', 8)
'old-valuNEW'
OVERLAY('NEW', 'old-value', 11)
'old-value NEW'
OVERLAY('NEW', 'old-value', 4, 2)
'oldNEalue'
OVERLAY('NEW', 'old-value', 9)
'old-valuNEW'

See also

JUSTIFY, SPACE, COPIES, CENTER, INSERT


POS

Finds the first occurrence of a substring within another string.

Synopsis
where = POS(searchfor, string, start)

Args

searchfor is which substring to search for (within string. If searchfor is an empty string, then 0 is returned to indicate no occurrences of searchfor within string.

string is the original string (to search for searchfor within).

start is which character position to start the search from, where 1 would be to start searching at the first character in string. If omitted, the default is to start searching from the first character. start must not be negative, nor have a fractional component -- it must be a positive whole number.

Returns

If searchfor is found, then POS() returns the character position where the first occurrence of searchfor occurs within string (where 1 is the first character within string). If searchfor is not found, then POS() returns 0.

Examples

Example use
Return value
LASTPOS('be', 'to be or not to be')
3
LASTPOS('to', 'to be or not to be', 10)
17
LASTPOS('to', 'to be or not to be', 18)
0
LASTPOS('is', 'to be or not to be')
0

See also

WORDPOS, LASTPOS, COUNTSTR, VERIFY


REVERSE

Reverses the order of characters in a string.

Synopsis
newstring = REVERSE(string)

Args

string whose characters are to be reversed.

Returns

A copy of the original string with the order of its characters reversed.

Notes

The original string is not altered. Only the return value of REVERSE has its characters reversed.

Examples

Example use
Return value
REVERSE('FooBar')
'raBooF'
REVERSE(' Foo Bar')
'raB ooF '
REVERSE('3.14159')
'95141.3'


RIGHT

Excerpts one or more characters from the right-hand side of a string.

Synopsis
excerpt = RIGHT(string, length, padchar)

Args

string is the original string (from which to excerpt characters).

length is the number of characters to be excerpted. If length is 0, no characters are excerpted. If length is greater than the number of characters in string, then the excerpt is padded out on the left with padchar characters to the desired length.

padchar is the character to use for padding (if the original string is not >= length). If padchar is omitted, the default is a space character.

Returns

A string containing the excerpted characters.

Notes

The original string is not altered.

Examples

Example use
Return value
RIGHT('Foo bar', 5)
'o bar'
RIGHT('Foo bar', 4)
' bar'
RIGHT('Foo bar', 10)
'   Foo bar'
RIGHT('Foo bar', 10, '*')
'***Foo bar'

See also

SUBSTR, LEFT, SUBWORD


STRIP

Removes leading and/or trailing space (or other) characters from a string.

Synopsis
newstring = STRIP(string, option, padchar)

Args

string whose leading and trailing space characters are to be removed.

padchar is the character to strip. If padchar is omitted, the default is a space character.

option determines whether padchars are stripped from the beginning and/or end of string. It must be one of the following:

Option
Meaning
L (Leading) Only leading characters are stripped. Trailing characters are not.
T (Trailing) Only trailing characters are stripped. Leading characters are not.
B (Both) Both leading and trailing characters are stripped.

Returns

A copy of the original string with its leading and trailing space characters removed.

Notes

The original string is not altered. Only the return value of STRIP has its leading/trailing padchars removed.

This removes only those padchars appearing at the front or end of the string. To delete padchars within the string, use SPACE().

When padchar is omitted, Reginald strips TAB characters as well as space characters. Other interpreters may strip only space characters (ie, not TAB).

Examples

Example use
Return value
STRIP('   FooBar')
'FooBar'
STRIP(' Foo Bar ')
'Foo Bar'
STRIP(' Foo Bar ', 'L')
'Foo Bar '
STRIP('  3.14159  ')
'3.14159'
STRIP('*** Foo *** Bar ***', ,'*')
' Foo *** Bar '

See also

SPACE, TRANSLATE


SUBSTR

Excerpts one or more characters from a string, and returns that excerpt.

Synopsis
excerpt = SUBSTR(string, start, length, padchar)

Args

string is the original string (from which to excerpt characters).

start is which character position to start the excerpt from, where 1 would be to start the excerpt at the first character in the string. If there are less characters in the string than start, then an empty string is returned. start cannot be 0 or negative, nor have a fractional component -- it must be a positive whole number.

length is the number of characters to be excerpted, starting at the character position start. If length is omitted, the default is to excerpt all characters from start to the end of the string. If length is 0, no characters are excerpted. length cannot be negative, nor have a fractional component -- it must be a positive integer.

padchar is the character to use for padding (if the original string is not >= length + start). If padchar is omitted, the default is a space character.

Returns

A string containing the excerpted characters.

Notes

Any leading or trailing spaces are not trimmed from the excerpt.

It is not an error if start or length (or a combination of them) refers to more characters than string actually contains.

The original string is not altered.

Examples

Example use
Return value
SUBSTR('Foo bar', 3)
'o bar'
SUBSTR('Foo bar', 3, 3)
'o b'
SUBSTR('Foo bar', 4, 6)
' bar  '
SUBSTR('Foo bar', 4, 6, '*')
' bar**'
SUBSTR('Foo bar', 9, 4, '*')
'****'

See also

SUBWORD, LEFT, RIGHT


TRANSLATE

Translates characters in a string to other characters, or makes a string uppercase.

Synopsis
newstring = TRANSLATE(string, tableout, tablein, padchar)

Args

string is the original string (to translate).

tablein is a string containing upto 256 characters, representing characters that you wish translated to the respective characters in tableout.

If one or both of the tables are specified, each character in string that exists in tablein is translated to the character in tableout that occupies the same position as the tablein character. Characters in string which are not found in tablein are left unchanged.

If omitted, tablein defaults to all 256 characters of the computer's default character set. If omitted, tableout defaults to an empty set.

If tableout is larger than tablein, the extra entries are ignored. If smaller than tablein, tableout is padded with padchar characters to the same length as tablein. If padchar is omitted, the default padding is space characters.

If both of the tables are omitted, TRANSLATE() upper-cases string.

If a character occurs more than once in tablein, only the first occurrence will matter.

Returns

A copy of the original string with each tablein character translated to its respective tableout's character.

Notes

The original string is not altered. Only the return value of TRANSLATE has its characters translated.

Examples

Example use
Return value
TRANSLATE('FooBar')
'FOOBAR'
TRANSLATE('FooBar', 'ABFORabfor', 'abforABFOR')
'fOObAR'
TRANSLATE('FooBar', 'abfor')
'F  B  '
TRANSLATE('FooBar', 'abfor', , '#')
'F##B##'

See also

CHANGESTR


VERIFY

Tests if any characters of one string also occur in another string.

Synopsis
where = VERIFY(string, lookfor, option, start)

Args

string is the string to search (for lookfor).

start is which character number to start searching from, where 1 would be to start searching at the first character in the string. If there are less characters in the string than start, then a 0 is returned to indicate that no characters in lookfor matched.

option must be one of:

Option
Meaning
N (Nomatch) Return the position of the first character in string that isn't found in lookfor, or 0 if all of the characters in string also exist in lookfor.
M (Match) Return the position of the first character in string that also exists in lookfor, or 0 none of the characters in string also exist in lookfor.

If omitted, option defaults to 'N'.

Returns

A character position (where 1 is the first character in string).

Notes

It is not an error if start refers to more characters than string actually contains.

Examples

Example use
Return value
VERIFY('foobar', 'barfo')
2
VERIFY('foobar', 'barfo', 'M')
2
VERIFY('foobar', 'fob', 'N')
5
VERIFY('foobar', 'barf', 'N', 3)
3
VERIFY('foobar', 'barf', 'N', 4)
0


XRANGE

Creates a range of characters between a given start character and end character. The range of characters is produced from the computer's character set.

Synopsis
newstring = XRANGE(start, end)

Args

start is which character to start from. If omitted, the default is to start from character 0 ('00'x).

end is which character to end at. If omitted, the default is to end at character 255 ('ff'x).

Returns

A string that consists of all the characters from start through end, inclusive.

Notes

The actual representation of the output from XRANGE() depends on the character set used by your computer.

If the value of start is larger than the value of end, the output will wrap around from ‘ff’x to ‘00’x. If start or end is not a string containing exactly one character, this raises a SYNTAX error.

Examples

Example use
Return value
XRANGE('A', 'J')
'ABCDEFGHIJ'
XRANGE('FC'x)
'FCFDFEFF'x
XRANGE(, '05'x)
'000102030405'x
XRANGE('FD'x, '04'x)
'FDFEFF0001020304'x

See also

VERIFY