Script commands are structured as individual lines of text that must begin with a command.
• | Commands/lines without a recognized command are skipped/no processed. |
• | Some commands incorrectly structured may cause the script processing to stop. |
• | There is no practical limit to the number of command lines that can be in one script file. |
• | Commands for dBase file 1 must begin with three characters db1 (only db1 is supported in this version). |
Command Summary
db1open | Opens a DBF |
db1saveas | Saves a DBF |
db1showfields | Shows DBF field names and attributes |
db1index1 | Indexes a DBF on fields |
db1useindex1 | Sets an existing index to active |
db1find | Finds a specific records using and indexed DBF |
db1profile | Displays all fields for current record (field name and field value) |
db1count | Counts records in active DBF; displays count. |
db1filter | Filters a DBF using DBF query (db1filter '' removes any existing filter) |
db1list | Displays list of user defined fields for active DBF -- one line per record |
db1copystruc | Copies the active DBF structure to a new DBF |
db1appendfrom | Appends records into the active DBF |
db1exclusive | Sets active DBF enabled/no enabled to be modified. |
db1newfield | Defines a new field in active DBF |
db1create | Creates a new DBF -- used in combination with db1newfield statements. |
db1assign | Assigns a value to an existing DBF field based on constants and other DBF fields |
Examples and Notes
db1open 'c:\cvxe\1\cb_2015_us_county_500k.dbf'
- db1open must be the first command in the script file.
- the command must be followed with full path and file name enclosed in ' characters.
- the file must be a dbase file and must show the dbf extension.
db1saveas 'c:\cvxe\1\temp.dbf'
- db1saveas may be located anywhere in the script file and might not be used at all.
- the command must be followed with full path and file name enclosed in ' characters.
- the output file may be of type cvs, txt or dbf.
db1close
- db1close may be located anywhere in the script file and might not be used at all.
- the command has no additional values following the command text.
- once a file is closed, the same or another file must be opened (db1open) for subsequent commands to operate.
db1open 'c:\cvxe\1\temp.dbf'
- see above; illustrates opening another dbase file in the same script.
db1showfields
- generates a display list of all field names and their attributes.
- the command has no additional values following the command text.
db1index1 statefp+countyfp
- creates an index file for the active dBase file.
- fields comprising the key must be entered to the right of the command.
- the above example illustrates use of the key defined as the concatenated statefp and countyfp fields.
- statefp is the state FIPS code; countyfp is the county FIPS code.
db1useindex1
- the db1index1 command (above) only creates an index.
- the db1useindex1 command makes the index active for the db1 dBase file.
- the command has no additional values following the command text.
db1find 04019
- performs a Find operation for a specified key value.
- the first data record matching the Find condition is selected.
- a Key value, matching the index structure, is required.
- the above example illustrates use of the key value 04019
- the messaging section indicates whether the Find was successful or not.
db1profile
- the db1find command above finds one record (in the example db1 file).
- the db1profile shows/displays all attributes for that db1 record.
- each field name and field value are displayed/listed in the messaging section.
- the command has no additional values following the command text.
db1count
- the db1count counts the active records in the db1 file and displays the count in the messaging section..
- in this example, there is still only 1 record selected.
- the command has no additional values following the command text.
db1filter geoid='04013'
- performs a Filer operation for a specified condition.
- data records matching the db1filter condition are selected.
- note that the condition is not a key value.
- the above example illustrates use of Filter to select any record where the field GEOID has the value 04013.
db1count
- the db1count counts the active records in the db1 file and displays the count in the messaging section..
- in this example, there is still only 1 record selected.
- the command has no additional values following the command text.
db1filter substr(geoid,1,2)='04'
- performs a Filer operation for a specified condition.
- data records matching the db1filter condition are selected.
- note that the condition is not a key value.
- the above example selects any record where the first 2 characters of field GEOID has the value 04.
db1count
- the db1count counts the active records in the db1 file and displays the count in the messaging section..
- in this example, there are 15 record selected -- each county in Arizona.
- the command has no additional values following the command text.
db1list geoid,pop2010,pop2015,chg1015p
- the db1list command display a line in the messaging section for each active record.
- field values for each record are listed in the messaging section.
- in this example, there are 15 record selected; 15 rows are displayed.
db1saveas 'c:\cvxe\1\cb_2015_us_county_500k_14.csv'
- the db1saveas command saves the active records to an output file.
- the output file name is provided in the command line.
- the file extension determines the format/structure of the output file:
- csv extension -- the file is written as a CSV structured file
- sdf or txt -- the file is written as a fixed-length field ACSII text file
- dbf -- the file is written as a dBase structured file
db1filter ''
- performs a Filer operation for a specified condition.
- data records matching the db1filter condition are selected.
- use of the '' (a null value) removes any existng db1filter.
db1count
- the db1count counts the active records in the db1 file and displays the count in the messaging section..
- in this example, all records have been seleected -- each county in the U.S.
- the command has no additional values following the command text.
Commands not active in this version include:
• | db1exclusive [true or false} |
• | db1import -- imports data into db1 |
• | db1assign -- assigns a computed value to a field |
• | db1insert -- inserts a field into db1 |
• | db1zap -- deletes all records |
• | use of other dBase files such as db2 through db9 |