home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a013 / 1.ddi / SOURCE.EXE / F_CHKSTA.PRG < prev    next >
Encoding:
Text File  |  1991-01-25  |  1009 b   |  47 lines

  1. *****************************************************************
  2. FUNCTION CHKSTATE (statecode)
  3. *****************************************************************
  4.  
  5. * Verifies a two character state code
  6.  
  7. * Copyright(c) 1991 -- James Occhiogrosso
  8.  
  9. LOCAL old_area := 0
  10.  
  11. * If passed state code exceeds 2 characters, take no action
  12. IF LEN(TRIM(statecode)) > 2
  13.    RETURN(.T.)
  14. ENDIF
  15.  
  16. * Save old work area
  17. old_area = SELECT()
  18.  
  19. * Make sure Zip Codes database is available
  20. SELECT zips
  21. IF EMPTY(ALIAS())
  22.     IF FILE('zips.dbf')
  23.         * If zips file exists, open it
  24.         SELECT 0
  25.         USE zips
  26.     ELSE
  27.         * Otherwise, return with no action
  28.         RETURN(.T.)
  29.     ENDIF
  30. ENDIF
  31.  
  32. * Check zips database for the state code
  33. statecode = UPPER(statecode)
  34. LOCATE FOR TRIM(statecode) $ zips->state
  35. IF FOUND()
  36.    AEDMSG('mw_pgdn')
  37.    SELECT(old_area)
  38.    RETURN(.T.)
  39. ELSE
  40.    ERRORBEEP()
  41.    AEDMSG('Invalid State - Please reenter')
  42.    SELECT(old_area)
  43.    RETURN(.F.)
  44. ENDIF
  45.  
  46.  
  47.