Amos Professional Manual  Contents  Index

String Functions


Chr$(27)+"RO"+A$+Chr$(27)+"R"+Chr$(48+n)

Getting information about strings
The next three functions are provided to discover particular properties of strings.

CHR$
function: return the character with a given ASCII code
s$=Chr$(code number)

The CHR$ function creates a string that contains a single character generated by a given ASCII code number. Note that only the characters with ASCII code numbers 32 to 255 are printable on the screen. Others are used internally as control codes. Match characters with their codes using this routine:

E> For S=32 To 255: Print Chr$(S); : Next S

ASC
function: Give the ASCII code of a character
code=Asc(a$)

To get the internal ASCII code of the first character in a string, use the ASC function like this:

E> Print Asc("B")
   Print Asc("AMOS Professional")

LEN
function: give the length of a string
length=Len(a$)

The LEN function returns the number of characters stored in a string. For example:

D> Print Len("0123456789")

Array operations
To end this Chapter, here are a pair of useful instructions for manipulating arrays.

SORT
instruction: sort all elements in an array
Sort a(0)
Sort a#(0)
Sort a$(0)

The SORT instruction arranges the contents of any array into ascending order, and the array may contain integers, floating point numbers or strings.

Back    Next
05.02.05