Вы находитесь на странице: 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

Вам также может понравиться