You basically need to open the database file, open a csv file as a sequential file, select the database file and loop through it, in each loop read the record in and then write it away as a csv. This may be as easy as converting attribute marks to commas, if there are subvalues you may want put some other character in. you then write the line to the csv file. It all depends on the data dictionary of the file you want to dump. It kinda sounds that you are talking some complex data here. A dump into CSV is fine for one set of simple data, but if you are talking multiple tables which have values and sub values (nested tables) you would have to produce a csv per table, value set and sub value set which would then get rather complex. Also if you are going to do anything with the data you need to know the data dictionary/schema so you know what to extract. Anyway an example bit of code to dump all records of a simple database file with no multi/sub values is :
OPEN 'FILENAME' TO dbFil ELSE STOP 201,'FILENAME'
OPENSEQ 'C:\FOLDER\FILE.CSV' TO csvFil ELSE STOP 201,'FILENAME'
SELECT dbFil
LOOP WHILE READNEXT dbID DO
READ dbRec FROM dbFil,dbID ELSE dbRec=''
line=CHANGE(dbRec,@AM,",")
WRITESEQ line APPEND ON csvFil ELSE CRT "error"
REPEAT
or something similar - that was just off the top of my head.