MIDSTR               ' C style


#include <STRING.bas>                        ' source in /Program Files/Coridium/BASIClib 

FUNCTION MIDSTR( string , start, length ) as STRING


This FUNCTION written in BASIC returning the portion of string from the start character for length characters.

String may be a constant or variable string.

MIDSTR is written in C style with 0 being the first character of the string, consistent with VB string.Chars(0).

Extracting or setting a single byte in a string can be done with an index STRING(3) refers to the 4th byte of the string (starts from 0).


#include <STRING.bas> 
DIM text(10)
text = "HELLO WORLD" 
PRINT MIDSTR(text, 4,5)     ' will display  O WOR

Differences from other BASICs

See also