◄Example► ◄Contents► ◄Index► ◄Back► ────────────────────────────────────────────────────────────────────────────── 'This example uses a recursive FUNCTION procedure (a function that calls 'itself) to find and return the length of a string. DECLARE FUNCTION StrgLng% (X$) CLS INPUT "Enter a string: "; InString$ PRINT "The string length is"; StrgLng%(InString$) FUNCTION StrgLng% (X$) IF X$ = "" THEN 'The length of a null string is zero. StrLng% = 0 ELSE 'Non-null string--make a recursive call. 'The length of a non-null string is 1 plus 'the length of the rest of the string. StrgLng% = 1 + StrgLng%(MID$(X$, 2)) END IF END FUNCTION