STRING VARIABLES AND STRING VARIABLE FUNCTIONS BASIC variables may be integers, floating point or string variables. Each of these type of variables may also be arrays of 1 or 2 dimensions. String variables are signified by having a dollar sign, $ , following the variable name. A string variable can contain from 0 to 255 ASCII characters(letters, numbers, and punctuation). A string variable is created by assigning the quantity in quotes to the variable. A$ ="KMS FUSION" B$ ="DOE CONTRACT" String variables may be concatonated to create larger strings, ie the expression C$ = A$ + " HAS A " + B$ creates a string C$ = "KMS FUSION HAS A ERDA CONTRACT". ~ BASIC posesses a number of built in functions to manipulate strings in a very simple manner. LEN(string) Determine the length of the string. l=LEN(A$) TRM$(string) Trim trailing blanks off a string variable B$ = TRM$(string) POS(string1,string2,expression) Search string1 for the position of the set of characters(string2) starting with the character number given by the expression (an integer). If POS does not find string2 it it returns a zero. The strings can be string variables or ASCII characters in quotes. X=POS("ABCDE","CD",1) In this example, starting at the first letter the string is searched for "CD" and returns a value of 3 to X. ~ SEG$(string,expression1,expression2) The SEG$ function is used to copy a segment of a string from position given by expression1 to an position given by expression2, into another string. A$ = SEG$("ABCDEFGHIJ",3,5) Sets A$ ="CDE" ASC(string) Converts the 1 character string to its ASCII decimal equivalent. CHR$(expression) Converts the expression(0 or greater) to the ASCII leter code corresponding to the decimal value of the expression mod 256. VAL(string) String may contain digits 0-9. Converts the one character string to its numeric value. X=VAL("9") yields an X value of 9. ~ STR$(expression) Takes the numeric value of the expression and converts it to a string variable. DAT$ CLK$ Returns the value of the current date or time to the string variable. X$ = CLK$ or PRINT DAT$