0% found this document useful (0 votes)
19 views

LEFT$ Function: Purpose

This document provides information about the LEFT$ function in GW-BASIC, which returns a substring comprising the leftmost n characters of a string. It gives the purpose, syntax, and an example of using LEFT$ to print the first three characters of the string "BASIC". It also briefly describes the similar MID$ and RIGHT$ substring functions.

Uploaded by

Raj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

LEFT$ Function: Purpose

This document provides information about the LEFT$ function in GW-BASIC, which returns a substring comprising the leftmost n characters of a string. It gives the purpose, syntax, and an example of using LEFT$ to print the first three characters of the string "BASIC". It also briefly describes the similar MID$ and RIGHT$ substring functions.

Uploaded by

Raj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

GW-BASIC User's Guide

LEFT$ Function
Purpose:
To return a string that comprises the left-most n characters of x$.

Syntax:
LEFT$(x$,n)

Comments:
n must be within the range of 0 to 255. If n is greater than LEN(x$), the entire string (x$) will be
returned. If n equals zero, the null string (length zero) is returned (see the MID$ and RIGHT$
substring functions).

Example:
10 A$="BASIC"
20 B$=LEFT$(A$, 3)
30 PRINT B$
RUN
BAS
The left-most three letters of the string "BASIC" are printed on the screen.

file:///C|/Documents%20and%20Settings/Lorenzo/Desktop/GW%20Basic/LEFTS.html28/03/2004 21.29.34
GW-BASIC User's Guide

MID$ Function
Purpose:
To return a string of m characters from x$ beginning with the nth character.

Syntax:
MID$(x$,n[,m])

Comments:
n must be within the range of 1 to 255.
m must be within the range of 0 to 255.
If m is omitted, or if there are fewer than m characters to the right of n, all rightmost characters
beginning with n are returned.
If n > LEN(x$), MID$ function returns a null string.
If m equals 0, the MID$ function returns a null string.
If either n or m is out of range, an "Illegal function call error" is returned.
For more information and examples, see the LEFT$ and RIGHT$ functions.

Examples:
10 A$="GOOD"
20 B$="MORNING EVENING AFTERNOON"
30 PRINT A$; MID$(B$, 8, 8)
RUN
GOOD EVENING
Line 30 concatenates (joins) the A$ string to another string with a length of eight characters,
beginning at position 8 within the B$ string.

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

You might also like