home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / High Level Languages / QBasic 4.5 / ADVR_EX / FUNC_EX.BAS < prev    next >
Encoding:
BASIC Source File  |  1988-09-20  |  436 b   |  17 lines

  1. ' *** FUNC_EX.BAS ***
  2.  
  3. LINE INPUT "Enter a string: ",InString$
  4. PRINT "The string length is"; StrLen(InString$)
  5.  
  6. FUNCTION StrLen(X$)
  7.    IF X$ = "" THEN
  8.       ' The length of a null string is zero.
  9.       StrLen=0
  10.    ELSE
  11.       ' Non-null string--make a recursive call.
  12.       ' The length of a non-null string is 1
  13.       ' plus the length of the rest of the string.
  14.       StrLen=1+StrLen(MID$(X$,2))
  15.    END IF
  16. END FUNCTION
  17.