PDA

View Full Version : Add tag to exported text file


ABC123

dparkins
02-18-2005, 08:11 AM
I have a script(below)that exports some records to a text file which works great. What I would like is to add a tag line to the beginning and end of the file.

Ex: "badge 2005 begin"
text file
"badge 2005 end"

Is this possible?
Thanks,
Dave

a_tbl = table.current()
query.order = "recno()"
record_number = current_record_number()
query.filter = "recno() = " + record_number
query.options = "I"
a_tbl.query_create()
export.type = 0
export.names = .T.
export.file = "c:\badge\badge_04.asc"
export.options = "Q"
export.field_sep = ","
export.record_sep = ""CR""LF""
export.fields = 21
export.field1 = "regis-"yearlyid"
export.field2 = "regis-"emid"
export.field3 = "regis-"ind_lname"
export.field4 = "regis-"ind_fname"
export.field5 = "regis-"ind_co"
export.field6 = "regis-"ind_alphco"
export.field7 = "regis-"ind_city"
export.field8 = "regis-"ind_state"
export.field9 = "regis-"badgfname"
export.field10 = "regis-"badglname"
export.field11 = "regis-"badgco"
export.field12 = "regis-"badg_city"
export.field13 = "regis-"badg_state"
export.field14 = "regis-"ind_title"
export.field15 = "regis-"ind_zip"
export.field16 = "regis-"ind_tel"
export.field17 = "regis-"ind_countr"
export.field18 = "regis-"ind_add"
export.field19 = "regis-"printtype"
export.field20 = "regis-"vipprintonbadge"
export.field21 = "regis-"color"
a_tbl.export()
topparent.show_all()
tbl = table.current()
tbl.query_detach_all()

Stan Mathews
02-18-2005, 09:06 AM
Run this after the export

fil = file.open("c:\badge\badge_04.asc",FILE_RW_EXCLUSIVE)
tmp = fil.bytes_get()
cont = fil.readb(tmp)
fil.seek(0)
fil.write_line("badge 2005 begin")
fil.writeb(cont)
fil.write_line("badge 2005 end")
fil.flush()
fil.close()

dparkins
02-18-2005, 11:00 AM
thank you stan, works great.

dave