Hello everyone!
I have a crazy and probably dumb question. I am creating an application which will import data from different sources (DBF, CSV, TXT) to a MySql Database. Everything is working just fine. But what I have right now is 3 procedures, each one to execute the import process based on the selected Radio option (DBF, CSV, TXT). For example: If I select the DBF Radio, then the importDBF procedure will be called. if I select the CSV Radio, the importCSV will be executed, and so on. I am using TDBF and Tsdf components to connect to my source files.
What I would like to do was create an unique procedure/function which will import the data either from DBF or CSV/TXT based on the passed type(DBF/CSV). So when I click the Radio DBF, it will call the importData procedure passing the TDBF type for the "sourceTableType". That way I only have one procedure to execute all my data type (DBF/CSV/TXT) instead of 1 procedure for each type.
My ideia was something like that:
procedure importData(dataSource:type);
begin
while not dataSource.EOF do begin
...
end;
end;
the caller should work like that:
imporData(dataModuleDB.dbfTables) for the TDBF component
or imporData(dataModuleDB.csvTables) for TSDF component
It seems simple but for some reason it does not work because in pascal, as far as I know, I have to define the data type before using the variable/object. So first i need to set dataSource type either as TDBF or TSDF in my implementation/interface, before I can use it on my procedure.
I hope I made myself clear enough, otherwise please ask me for more details about the thing.
Thanks a lot guys.