# LONGSTRING

Compatible with:
DOS Maximite CMM MM150 MM170 MM+ MMX Picromite ArmiteL4 Armite F4 ArmiteH7 Picomite CMM2

Syntax:
LONGSTRING xxx

Description:

The LONGSTRING commands allow for the manipulation of strings longer than the normal MMBasic limit of 255 characters.
Variables for holding long strings must be defined as single dimensioned integer arrays with the number of elements set to the number of characters required for the maximum string length divided by eight.
The reason for dividing by eight is that each integer in an MMBasic array occupies eight bytes. Note that the long string routines do not check for overflow in the length of the strings.
If an attempt is made to create a string longer than a long string variable's size the outcome will be undefined.

LONGSTRING APPEND array%(), string$
Append a normal MMBasic string to a long string variable. array%() is a long string variable while string$ is a normal MMBasic string expression.

LONGSTRING CLEAR array%()
Will clear the long string variable array%(). ie, it will be set to an empty string.

LONGSTRING COPY dest%(), src%()
Copy one long string to another. dest%() is the destination variable and src%() is the source variable. Whatever was in dest%() will be overwritten.

LONGSTRING CONCAT dest%(), src%()
Concatenate one long string to another. dest%() is the destination variable and src%() is the source variable. src%() will the added to the end of dest%() (the destination will not be overwritten).

LONGSTRING LCASE array%()
Will convert any uppercase characters in array%() to lowercase. array%() must be long string variable.

LONGSTRING LEFT dest%(), src%(), nbr
Will copy the left hand 'nbr' characters from src%() to dest%() overwriting whatever was in dest%(). ie, copy from the beginning of src%(). src%() and dest%() must be long string variables.
'nbr' must be an integer constant or expression.

LONGSTRING LOAD array%(), nbr, string$
Will copy 'nbr' characters from string$ to the long string variable array%() overwriting whatever was in array%().

LONGSTRING MID dest%(), src%(), start, nbr
Will copy 'nbr' characters from src%() to dest%() starting at character position 'start' overwriting whatever was in dest%(). ie, copy from the middle of src%().
'nbr' is optional and if omitted the characters from 'start' to the end of the string will be copied src%() and dest%() must be long string variables.
'start' and 'nbr' must be an integer constants or expressions.

LONGSTRING PRINT [#n,] src%()
Prints the longstring stored in ‘src%()’ to the file or COM port opened as ‘#n’. If ‘#n’ is not specified the output will be sent to the console.

LONGSTRING REPLACE array%() , string$, start
Will substitute characters in the normal MMBasic string string$ into an existing long string array%() starting at position ‘start’ in the long string.

LONGSTRING RESIZE n
Sets the size of the longstring to n.
This overrides the size set by other longstring commands so should be used with caution. Typical use would be in using a longstring as a byte array.

LONGSTRING RIGHT dest%(), src%(), nbr
Will copy the right hand 'nbr' characters from src%() to dest%() overwriting whatever was in dest%(). ie, copy from the end of src%().
src%() and dest%() must be long string variables.
'nbr' must be an integer constant or expression.

LONGSTRING SETBYTE data , n
Sets byte n to the value data, n respects OPTION BASE

LONGSTRING TRIM array%(), nbr
Will trim ‘nbr’ characters from the left of a long string. array%() must be a long string variables.
'nbr' must be an integer constant or expression.

LONGSTRING UCASE array%()
Will convert any lowercase characters in array%() to uppercase.
array%() must be long string variable.

Functions:

LCASE$( string$ )
Returns ‘string$’ converted to lowercase characters.

LCOMPARE(array1%(),array2%())
Compare the contents of two long string variables array1%() and array2%().
The returned is an integer and will be -1 if array1%() is less than array2%().
It will be zero if they are equal in length and content and +1 if array1%() is greater than array2%().
The comparison uses the ASCII character set and is case sensitive.

LEFT$( string$, nbr )
Returns a substring of ‘string$’ with ‘nbr' of characters from the left (beginning) of the string.

LGETBYTE(array%(), n)
Returns the numerical value of the 'n'th byte in the LONGSTRING held in 'array%()'.
This function respects the setting of OPTION BASE in determining which byte to return.

LGETSTR$(array%(), start, length)
Returns part of a long string stored in array%() as a normal MMBasic string.
The parameters start and length define the part of the string to be returned.

LINSTR(array%(), search$ [,start])
Returns the position of a search string in a long string. The returned value is an integer and will be zero if the substring cannot be found.
array%() is the string to be searched and must be a long string variable.
Search$ is the substring to look for and it must be a normal MMBasic string or expression (not a long string). The search is case sensitive.
Normally the search will start at the first character in 'str' but the optional third parameter allows the start position of the search to be specified.

LLEN(array%())
Returns the length of a long string stored in array%()

Last edited: 25 February, 2021