Acorn Computers BBC Micro Model B w/8271 — Acorn BBC Micro Model B w/8271 User Guide Manual PDF

266 MID$ Purpose To copy part of one string into another string. For example, if then the middle part of demo$ , starting at position four and going on for three letters, ie demo$="DOGMATIC" MID$(demo$,4,3) would equal MAT . In fact MID$ can be used to copy any part of a string – not just the middle part. Thus MID$(demo$,1,3) would equal DOG and MID$(demo$,5,4) would be ATIC . This string function is very useful for selecting one word out of a long line. There is a demonstration program under the keyword GOSUB and another under the keyword LEN . If the last number is omitted then the function returns with the rest of the string.

Example RESTofLINES=MID$(main$,10) Description A string function which returns a sub-section of the first argument’s string. The second argument gives the starting position and the third argument gives the number of characters to be copied. If the source string is too short then the function returns as many characters as possible from the starting position. Syntax = MID$ ( , [ , ]) Associated keywords LEFT$ , RIGHT$ , LEN , INSTR