CSTATES Function
Syntax
Arguments
- format
"A" to retrieve abbreviations for state names, "S" to retrieve full state names.
Description
Return the US states with optional format S=state, A=Abbreviation.
Discussion
CSTATES() returns a character string containing the names or abbreviations for the states of the United States, United States territories, the District of Columbia, and all of the Canadian Provinces.
Example
? cstates("a" + crlf() ) = AL AK AZ AR CA CO ... ? cstates("a,") = "AL,AK,AZ,AR,CA,CO,CT,DE ... ? cstates("A|S"+ crlf() ) = AL|Alabama AK|Alaska AZ|Arizona AR|Arkansas CA|California ... ? cstates("s|a"+ crlf() ) = Alabama|AL Alaska|AK Arizona|AZ Arkansas|AR California|CA Colorado|CO ...
If you needed to create a drop-down listbox for an HTML page, your could be.
list = cstates("s|a"+ crlf() ) list = a5_html_list_populate(list,"MA")
This example creates a function that uses the CSTATES() expression to test whether a state abbreviation is legitimate. In this case the ATC() function returns a value greater than 0 for any two character string contained in the list of states.
function valid_state_abbreviation as L ( abbr as C ) dim i as N dim ab as C for i = 1 to 71 ab = ab + substr(cstates("A"), i * 2 - 1, 2) + crlf() next i if (atc(abbr, ab, 1) > 0) then valid_state_abbreviation = .T. else valid_state_abbreviation = .F. end if end function
This example creates a function that uses the CSTATES() expression to test whether a state name is legitimate. The ATC() function returns a value greater than 0 for any name contained in the list of states.
function valid_state_name as L (nam as C ) dim ab as C ab = cstates("S") if (atc(nam, ab, 1) > 0) then valid_state_name = .T. else valid_state_name = .F. end if end function
See Also