
Commands - 78
MID$
String Statement
SYNTAX: MID$(a$,s [,n]) = b$
PURPOSE: To replace a portion of one string with another.
REMARK S: A common usage for the MID$ statement is in networking protocols. The network commands are
standard strings defined by string variables.
Using the MID$ statement to modify these strings is much faster than other str ing methods.
The string a$ is the target string, while b$ is the replacement string.
The parameter s is the starting point within a$ where b$ will be inserted. The optional parameter n
indicates how many characters of b$ are to be used. W hen n is omitted, all of b$ is used.
If b$ is longer than a$, replacem ent will not exceed the length of a$. No error message will be
given.
RELATED: LEFT$, LEN, RIG HT$, INSTR, MID$ F unction
EXAMPLE: 10 F$ = "Hopeless"
20 R$ = "Help"
30 MID$(F$,1) = R$
40 PRINT F$
Helpless
The example below is for a comm unications protocol. Note that the escape cha racter is not a
printable character.
10 CV$=CHR(27) + "A" + "12"
20 MID$(CV$,3) = "23"
30 PRINT CV$
ESC A23
ERROR: < Data negative> – for s and n
< Data out of range> – if s = 0
< Data > 255> – for s and n
Comentários a estes Manuais