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

Appendix E<br />

Converting BASIC Programs to GW-BASIC<br />

Programs written in a BASIC language other than GW-BASIC may require some minor<br />

adjustments before they can be run. The following sections describe these adjustments.<br />

E.1 String Dimensions<br />

Delete all statements used to declare the length of strings. A statement such as the following:<br />

DIM A$(I,J)<br />

which dimensions a string array for J elements of length I, should be converted to the following<br />

statement:<br />

DIM A$(J)<br />

Some GW-BASIC languages use a comma or ampersand (&) for string concatenation. Each of<br />

these must be changed to a plus sign (+), which is the operator for GW-BASIC string<br />

concatenation.<br />

In GW-BASIC, the MID$, RIGHT$, and LEFT$ functions are used to take substrings of strings.<br />

Forms such as A$(I) to access the Ith character in A$, or A$(I,J) to take a substring of A$ from<br />

position I to position J, must be changed as follows:<br />

Other BASICGW-BASIC<br />

X$=A$(I) X$=MID$(A$,I,1)<br />

X$=A$(I,J) X$=MID$(A$,I,J-I+1)<br />

If the substring reference is on the left side of an assignment, and X$ is used to replace characters<br />

in A$, convert as follows:<br />

Other BASICGW-BASIC<br />

A$(I)=X$ MID$(A$,I,1)=X$<br />

A$(I,J)=X$ MID$(A$,I,J-I+1)=X$<br />

E.2 Multiple Assignments<br />

Some GW-BASIC languages allow statements of the following form to set B and C equal to zero:<br />

10 LET B=C=0<br />

GW-BASIC would interpret the second equal sign as a logical operator and set B equal to -1 if C<br />

equaled 0. Convert this statement to two assignment statements:<br />

10 C=0: B=0<br />

file:///C|/Documents%20and%20Settings/Lorenzo/Desktop/GW%20Basic/Appendix%20E.html (1 of 2)28/03/2004 21.29.06

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

Saved successfully!

Ooh no, something went wrong!