String Constants, Variables & Operators


A string is a sequence of alphanumeric characters (8-bit ASCII codes) which collectively form an entity.

1.     String Constants

A string constant may contain from 0 to 70 characters enclosed in double quotation marks. e.g.

"TBASIC made PLC numeric processing a piece of cake!"
"$102,345.00"

 

2.     String Variables

TBASIC supports a maximum of 26 string variables A$, B$ ... Z$. Each string variable may contain from 0 (null string) up to a maximum of 70 characters.

 

3.     String Operators

i) Assignment Operator: A string variable (A to Z, DM and system variables, etc) may be assigned a string expression using the assignment statement:

A$ = "Hello, Welcome To TBASIC"
Z$ = MID$(A$,3,5)

ii) Concatenation Operators: Two or more strings can be concatenated (joined together) simply by using the "+" operator. e.g.

M$ = "Hello " + A$ + ", welcome to " + B$

If A$ contains "James", and B$ contains "TBASIC", M$ will contain the string: "Hello James, welcome to TBASIC".

iii) Comparison Operators: Two strings may be compared for equality by using the function STRCMP(A$,B$). However, the integer comparator such as "=", "<>", etc cannot be used for string comparison.

iv) Functional Operators: TBASIC supports a number of statement and functions which take one or more string arguments and return either an integer or a string value. e.g.

LEN(x$), MID$(A$,x,y), PRINT #1 A$,.... SETLCD 1, x$ VAL(x$),


backbutton.gif (507 bytes)  Basic to TBASIC Reference Manual