home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 24 / CD_ASCQ_24_0995.iso / vrac / homonlib.zip / ISALPHA.BAS < prev    next >
BASIC Source File  |  1995-04-13  |  1KB  |  34 lines

  1. DEFINT A-Z
  2.  
  3. ' $INCLUDE: 'TRUEFALS.INC'
  4.  
  5. DECLARE FUNCTION IsAlpha (text$)
  6.  
  7. FUNCTION IsAlpha (text$)
  8. '****************************************************************************
  9. 'Returns TRUE if the text contains only letters and spaces, otherwise FALSE.
  10. '****************************************************************************
  11.  
  12. IF text$ = "" THEN                           'If text$ is a null string,
  13.      IsAlpha = TRUE                          'return TRUE (What the heck,
  14.      EXIT FUNCTION                           'it's not numeric!)
  15. END IF
  16.  
  17. allowed$ = " ABCDEFGHIJKLMNOPQRSTUVWXYZ"     'Define the allowed characters.
  18.                                              '(The space is there on purpose)
  19. FOR x = 1 TO LEN(text$)
  20.                                              'Go through text$ one character
  21.      c$ = UCASE$(MID$(text$, x, 1))          'at a time (upper case).
  22.  
  23.      IF INSTR(allowed$, c$) = 0 THEN         'If any character does not
  24.           IsAlpha = FALSE                    'appear within allowed$, it is
  25.           EXIT FUNCTION                      'not alpha.
  26.      END IF
  27.  
  28. NEXT x
  29.  
  30. IsAlpha = TRUE                               'All tests passed to get here.
  31.  
  32. END FUNCTION
  33.  
  34.