Amos Professional Manual  Contents  Index

String Functions


To perform the reverse task to STR$, the VAL function converts a list of decimal digits stored in a string, changing them into a number. If this process fails for any reason, a value of zero will be returned. For example:

D> X=Val("1234") : Print X

STRING$
function: create a new string from an existing string
new$=String$(existing$, number)

Do not confuse this with STR$, which converts numbers into a string. The STRING$ function creates a new string filled with the required number of copies of the first character from an existing string. For instance, the following example produces a new string containing ten copies of the character "A".

E> Print String$("AMOS Professional is a joy forever",10)

Manipulating strings
Sometimes you may want to handle your strings for special purposes. For example, if you wish to pad out a piece of text before it gets printed onto the screen, you will need an accurate method of creating spaces in the string.

SPACE$
function: space out a string
s$=Space$(number of spaces)

Try the following example:

E> Print "Ten";Space$(10);"spaces"

FLIP$
function: invert a string
inverted$=Flip$(original$)

This function simply reverses the order of the characters held in an existing string. For example:

D> Print Flip$("SOMA gnippilf")

REPEAT$
function: repeat a string
r$=Repeat$(text$,number)

To repeat the same string of characters using a single PRINT statement, follow your string of text with the number of times you want the repetition. Allowable values are between 1 and 127. Whenever the string is printed, a sequence of control characters is automatically added to the r$ variable, in the following format:

Back    Next
05.02.04