Amos Professional Manual  Contents  Index

String Functions


    If X<>0 Then Print G$;" Found at position ";X
   Loop

Normally, the search will begin from the first character at the extreme left-hand side of the host string, but you may begin searching from any position by specifying an optional number of characters from the beginning of the host string. The optional start-of-search position can range from zero to the maximum number of characters in the host string to be searched. For example:

E> Print Instr("AMOS PROFESSIONAL","O",0)
   Print Instr("AMOS PROFESSIONAL","O",4)

Converting strings

UPPER$
function: convert a string of text to upper case
new$=Upper$(old$)

This function converts the characters in a string into upper case (capital) letters, and places the result into a new string. For example:

D> Print Upper$("aMoS pRoFeSsIoNaL")

LOWER$
function: convert a string of text to lower case
new$=Lower$(old$)

This works in the same way as UPPERS, but translates all the characters in a string into nothing but lower case (small) letters. These sorts of text conversions are particularly useful for interpreting user-input in interactive data programs and adventure games, because input can be converted into a standard format which is understood by your programs. For example:

E> Input "Do you want to continue? (Yes or No)";ANSWER$
   ANSWER$=Lower$(ANSWER$) : If ANSWER$="no" Then Edit
   Print "OK. Continuing with your program"

STR$
function: convert a number into a string
s$=Str$(number)

Str$ converts a real number variable into a string. This can be used to overcome limitations posed by functions like CENTRE, which does not accept numbers as parameters, but will work happily with parameters in the form of strings. Here is an example:

E> Centre "Remaining memory is"+Str$(Chip Free)+" Bytes"

VAL
function: convert a string of digits into a number
v=Val(x$)
v#=Val(x$)

Back    Next
05.02.03