Support 805.461.7300
Sales
Our Technology. Your Success.

Add a field to the beginning of a database

*********************************************
comNewFieldName="newfield"
comNewFieldSize=10
comNewFieldType="C"

*********************************************
*Get current database path
comDatabasePath=DBF()
*Construct New Field
comFieldString=comNewFieldName+" "+comNewFieldType+"("+allt(STR(comNewFieldSize))+")"
*Create temporary working file
comTempDbf1=FORCEEXT("t"+SUBSTR(SYS(2015),2),'dbf')
comTempDbf2=FORCEEXT("t"+SUBSTR(SYS(2015),2),'dbf')
*Make copy of current database structure
COPY STRUCTURE EXTENDED TO (comTempDbf1)
*Open structure database
USE (comTempDbf1) ALIAS "_stucture"
*Add new field
ALTER TABLE "_stucture" ADD COLUMN recnum N(3)
REPLACE ALL recnum WITH RECNO()
*Add blank record to structure database
APPEND BLANK
REPLACE field_name WITH comNewFieldName, field_type WITH comNewFieldType, field_len WITH comNewFieldSize
*Write new structure with new field at top
SORT TO (comTempDbf2) ON recnum FIELDS EXCEPT recnum
USE (comTempDbf2) ALIAS "_stucture"
SELECT * FROM "_stucture" INTO ARRAY _newdatabase
USE
*Create new database
CREATE TABLE (FORCEEXT(comDatabasePath,"")+"t.dbf") FROM ARRAY _newdatabase
*Append records from original database
APPEND FROM (comDatabasePath)
*Close new database
USE
*Rename original database with unique name
RENAME (comDatabasePath) TO (FORCEEXT(comDatabasePath,"")+SYS(2015)+".dbf")
RENAME (FORCEEXT(comDatabasePath,"")+"t.dbf") TO (comDatabasePath)
*Cleanup
DELETE FILE(comTempDbf1)
DELETE FILE(comTempDbf1)
*Open new database as original database name
USE (comDatabasePath)

« Back to Commands

I was looking for an easy to use all-in-one postal software solution and was working with Satori Software. They quoted me $10,000.00 which was out of the realm of our budget. I was also lead to believe that they were the only solution, until I found Accuzip. I was able to save my company over $9,000.00 with one phone call to your courteous and knowledgeable sales staff. Your product does everything that we need and much much more. Thank you Accuzip!
J.S., Newark, OH