home *** CD-ROM | disk | FTP | other *** search
- *****************************************************************
- FUNCTION CHKZIP (statecode, zipcode)
- *****************************************************************
-
- * Verify range of first five characters of U.S. Zip Codes
-
- * Copyright(c) 1991 -- James Occhiogrosso
-
- LOCAL old_area := 0
-
- * If passed statecode exceeds 2 characters, exit
- IF LEN(TRIM(statecode)) > 2
- RETURN(.T.)
- ENDIF
-
- * Save current area and select Zip Code file
- old_area = SELECT()
- SELECT zips
-
- * Make sure Zip Code database is available
- IF EMPTY(ALIAS())
- IF FILE('zips.dbf')
- * If Zips file exists, open it
- SELECT 0
- USE zips
- ELSE
- * Otherwise, exit
- RETURN(.T.)
- ENDIF
- ENDIF
-
- * If ZIPS pointer is not on correct state, move it
- IF UPPER(SUBSTR(statecode,1,2)) != zips->state
- LOCATE FOR UPPER(TRIM(statecode)) $ zips->state
- ENDIF
-
- * Validate first 5 digits of passed Zip Code
- IF LEN(TRIM(SUBSTR(zipcode,1,5))) > 4 ;
- .AND. zipcode >= zips->lozip .AND. zipcode <= zips->hizip
-
- * Restore normal add/edit message and return
- AEDMSG('mw_pgdn')
- * Reselect original area and return
- SELECT(old_area)
- RETURN(.T.)
-
- ELSE
- * Sound an error beep
- ERRORBEEP()
- IF .NOT. FOUND()
- AEDMSG('State not in database')
- ELSE
- * Otherwise, display correct range
- AEDMSG('Range for ' + SUBSTR(statecode,1,2) + ' is ' + ;
- zips->lozip + ' to ' + zips->hizip)
- ENDIF
-
- * Reselect original area and return
- SELECT(old_area)
- RETURN(.F.)
-
- ENDIF
-
-