NAME

lmrS - left, middle and right portions of a string

SYNOPSIS

#include <basic/string.h>

struct string leftS(s, n)
struct string *s;
short n;

struct string midS1(s, n, m, flag)
struct string *s;
short n, m;
int flag;

struct string rightS(s, n)
struct string *s;
short n;

DESCRIPTION

LeftS allocates and returns a copy of the first (left-most) n characters of the string pointed to by s.  If n is zero, the null string is returned.  If n is greater than the length of the string, a copy of the entire string is returned.  This function implements the BASIC LEFT$ function. 

MidS1 allocates and returns a string which consists of the portion of the string pointed to by s beginning with location n.  Locations are numbered starting with one.  If flag is set, a copy of the remainder of the string is returned.  Otherwise, a copy of the next m characters is returned.  If flag is clear and m is zero, the null string is returned.  Similarly if location n lies beyond the end of the string, the null string is returned.  If flag is clear and m is larger than the number of characters remaining in the string, a copy of the remainder of the string is returned.  This function implements the BASIC MID$ function. 

RightS allocates and returns a copy of the last (right-most) n characters of the string pointed to by s.  If n is zero, the null string is returned.  If n is greater than the length of the string, a copy of the entire string is returned.  This function implements the BASIC RIGHT$ function. 

SEE ALSO

string(inc)
left$(func), mid$(func), right$(func)

DIAGNOSTICS

Error 5 (Illegal function call) is generated by leftS and rightS if n is negative and by midS1 if n is non-positive or if flag is set and m is negative. 

from The Basmark QuickBASIC Programmerís Manual by Lawrence Leinweber