I'm wanting to write a script that appends some data from a Quattro Pro
v8 spreadsheet to an existing Paradox table. It works fine using the
import command from the menu - so I tried writing some code to perform
the import when a button is hit on my form.
I tried using the ImportSpreadsheet() command, but it fails because the
table I want to import into is already in use - by the form itself.
Plus, I'm unsure if the ImportSpreadsheet() command appends or replaces
the table.
I wrote the following code, which works, but seems real stupid to me:
method pushButton(var eventInfo Event)
var
filename String
fbi FileBrowserInfo
endvar
fbi.Title = "Select robot"
fbi.AllowableTypes = fbQuattroProWindows
fileBrowserEx(filename,fbi)
importSpreadsheet(filename,"temp.db","Tables:K2","Tables:AT3",true)
exportAsciiVar("temp.db","temp.csv")
appendAsciiVar("temp.csv", "robots.db")
delete("temp.db")
delete("temp.csv")
endMethod
So is there a better way to do this?
Thanks for your help...
--
+--------------------------------------------------------------------+
| Andrew, Christine, and Matthew Akins |
| Home: ig...@ames.net - http://www.ames.net/igor/ |
| Work: an...@cms-gt.com - http://www.cms-gt.com/ |
+--------------------------------------------------------------------+
| May your villages remain ignorant of tax collectors, and may your |
| sons be many and ugly and strong and willing workers, and may your |
| daughters be few and beautiful and excellent providers of love |
| gifts from eminent families that live very far away, and may your |
| lives be blessed by the beauty that has touched mine. |
| - Number Ten Ox, "Bridge of Birds" |
+--------------------------------------------------------------------+
The Akins skrev:
importSpreadsheet(filename,":priv:__temp.db","Tables:K2","Tables:AT3",true)
;All table names beginning with two underscores are deleted by Paradox on
exit
;The true in the importSpreadSheet specifies whether to treat the first
line of data as field ;names. If you add the data in the spreadsheet to
an existing table this does not
;seem to be necessary
add(":priv:__temp.db", ":work:robots.db", TRUE, FALSE)
;The TRUE specifies that data is appended to Robots.db
;The FALSE specifies that existing data (with the same key) in Robots.db
; is NOT updated (read replaced) by newer data from your spreadsheet
endMethod
--
Michael
Remove NOSPAM to reply