The MID$ function returns a string of m characters from x$ string, beginning with the n th character.
Syntax
LN MID$ (x$,n,m)
Where,
LN : Line Number
x$ : string from which the m characters are to be extracted starting from nth character.
n : the position from which character are to be extracted.
m : number of character.
n must be within the range 1 to 255.
m must be within the range of 0 to 255.
if m = 0, the MID$ function returns a null string.
Examples
10 LET P$= "GOLDEN RING"
20 LET Q$= MID$(P$,2,3)
Use of MID$ function in the program.
1. CS 8.5 Display on the screen for MID$ function
Ok
LIST
10 REM use of MID$ function
20 P$ = "GOLDEN RING"
30 Q$= MID$ (P$,2,3)
40 PRINT "Original String :-"; P$
50 PRINT "Extracted String :-" Q$
60 END
Ok
RUN
Original String :- GOLDEN RING
Extracted String :- OLD
Ok
2. CS 8.6 Display on the screen for MID$ function
Ok
10 REM Learning the use of MID$ function
20 P$= "KATHMANDU"
30 FOR I= 2 TO 3
40 FOR J= 1 TO 6
50 PRINT MID$(P$,I,J)
55 NEXT J
60 NEXT I
80 END
RUN
A
AT
ATH
ATHM
ATHMA
ATHMAN
T
TH
THM
THMA
THMAN
THMAND