17.07.2013 Views

GWBASIC User's Manual

GWBASIC User's Manual

GWBASIC User's Manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

GW-BASIC <strong>User's</strong> Guide<br />

A function is used in an expression to call a predetermined operation that is to be performed on<br />

an operand. GW-BASIC has intrinsic functions that reside in the system, such as SQR (square<br />

root) or SIN (sine).<br />

GW-BASIC also allows user-defined functions written by the programmer. See the DEF FN<br />

statement in the GW-BASIC <strong>User's</strong> Reference.<br />

6.4.5 String Operators<br />

To compare strings, use the same relational operators used with numbers:<br />

OperatorMeaning<br />

= Equal to<br />

Unequal<br />

< Less than<br />

> Greater than<br />

= Greater than or equal to<br />

The GW-BASIC Interpreter compares strings by taking one character at a time from each string<br />

and comparing their ASCII codes. If the ASCII codes in each string are the same, the strings are<br />

equal. If the ASCII codes differ, the lower code number will precede the higher code. If the<br />

interpreter reaches the end of one string during string comparison, the shorter string is said to be<br />

smaller, providing that both strings are the same up to that point. Leading and trailing blanks are<br />

significant.<br />

For example:<br />

"AA" < "AB"<br />

"FILENAME" = "FILENAME"<br />

"X&" > "X#"<br />

"CL " > "CL"<br />

"kg" > "KG"<br />

"SMYTH" < "SMYTHE"<br />

B$ < "9/12/78" where B$ = "8/12/78"<br />

String comparisons can also be used to test string values or to alphabetize strings. All string<br />

constants used in comparison expressions must be enclosed in quotation marks.<br />

Strings can be concatenated by using the plus (+) sign. For example:<br />

10 A$="FILE":B$="NAME"<br />

20 PRINT A$+B$<br />

30 PRINT "NEW " + A$+B$<br />

file:///C|/Documents%20and%20Settings/Lorenzo/Desktop/GW%20Basic/Chapter 6.html (11 of 12)28/03/2004 21.29.00

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!