Amos Professional Manual  Contents  Index

String Functions


In this Chapter, you will learn how to handle strings. AMOS Professional Basic has a full range of string manipulation instructions, and experienced Basic programmers should already be familiar with the standard syntax used.

Reading characters in a string

LEFT$
function: return the leftmost characters of a string
destination$=Left$(source$,number)
Left$(destination$,number)=source$

LEFT$ reads the specified number of characters in a source string, starting from the left-hand side, and copies them into a destination string. The first type of usage of this function creates a new destination string from the chosen number of characters of the source string. For example:

E> Do
    Input "Type in a string:";S$
    Print "Display how many characters from"
    Input "the left?";N
    Print Left$(S$,N)
   Loop

The second type of usage replaces the leftmost number of characters in the destination string with the equivalent number of characters from the source string. For example:

E> A$="**** Basic"
   Left$(A$,4)="AMOS"
   Print A$

Exactly the same processes can be performed with characters from the right-hand side of a string, by using the equivalent RIGHT$ function.

RIGHT$
function: return the rightmost characters of a string
destination$=Right$(source$,number)
Right$(destination$,number)=source$

Here are two examples demonstrating each version of usage:

E> Print Right$("IGNORED54321",5)
   A$=Right$("REJECTED0123456789",10)
   Print A$
  
E> B$="AMOS ************"
   Right$(B$,12)="Professsional"
   Print B$
Back    Next
05.02.01