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 />

DEFINT/SNG/DBL/STR Statements<br />

Purpose:<br />

To declare variable types as integer, single-precision, double-precision, or string.<br />

Syntax:<br />

DEFtype letters<br />

Comments:<br />

type is INT (integer), SNG (single-precision number), DBL (double-precision number), or STR<br />

(string of 0-255 characters).<br />

letters are letters (separated by commas) or range of letters of the alphabet.<br />

A DEFtype statement declares that variable names beginning with the letter(s) specify that type<br />

of variable. However, a type declaration character (%,!,#,$) always takes precedence over a<br />

DEFtype statement in the typing of a variable.<br />

If no type declaration statements are encountered, BASIC assumes all variables are singleprecision.<br />

Single-precision is the default value.<br />

Examples:<br />

10 DEFDBL L-P<br />

All variables beginning with the letters L, M, N, O, and P will be double-precision variables.<br />

10 DEFSTR A<br />

20 A="120#"<br />

All variables beginning with the letter A will be string variables. The $ declaration is unnecessary<br />

in this example.<br />

10 DEFINT I-N, W-Z<br />

20 W$="120#"<br />

All variables beginning with the letters I, J, K, L, M, N, W, X, Y, Z will be integer variables. W$<br />

in Line 20 establishes a string variable beginning with the letter W. However, the variable W will<br />

remain an integer elsewhere in the program.<br />

file:///C|/Documents%20and%20Settings/Lorenzo/Desktop/GW%20Basic/DEFINT.html28/03/2004 21.29.22

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

Saved successfully!

Ooh no, something went wrong!