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

MID$ Statement<br />

Purpose:<br />

To replace a portion of one string with another string.<br />

Syntax:<br />

MID$(stringexp1,n[,m])=stringexp2<br />

Comments:<br />

Both n and m are integer expressions.<br />

stringexp1 and stringexp2 are string expressions.<br />

The characters in stringexp1, beginning at position n, are replaced by the characters in<br />

stringexp2.<br />

The optional m refers to the number of characters from stringexp2 that are used in the<br />

replacement. If m is omitted, all of stringexp2 is used.<br />

Whether m is omitted or included, the replacement of characters never goes beyond the original<br />

length of stringexp1.<br />

Examples:<br />

10 A$="KANSAS CITY, MO"<br />

20 MID$(A$, 14)="KS"<br />

30 PRINT A$<br />

RUN<br />

KANSAS CITY, KS<br />

Line 20 overwrites "MO" in the A$ string with "KS".<br />

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

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

Saved successfully!

Ooh no, something went wrong!