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 a quantity in quotes to the variable: A$ ="KMS FUSION" B$ ="ERDA CONTRACT" String variables may be concatenated to create larger strings, i.e., 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 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 a position given by expres- sion2, 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 letter code corresponds 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$