I write utilities for another application which has over 20 tables of which I need some 15 or so open.
In the past my prg has individual openings for each table like
<code>
If !Used(cMyTableName14)
Use (cMyTableName14)Alias TEMP_NPV In 0 Excl
If lTableError = .T.
Do ermsg With 'TEMP_NPV'
Endif
Endif
</code>
where cMyTableName14 is the full file path
However if one of the required tables is absent I get an 'open' error.
So I decided to test for that - function file(cTable) let me down so I used ADIR()
INSTALLS is already open
My calling command is
Do tbl_opening With cMyTableName14,'TEMP_NPV'
my opening routine is
<code>
Procedure tbl_opening
Parameters myfile,tempter
Local gnPos,gcname
**** was using if file(myfile)
Adir(gadatabase, '*.dbf')
gcname=Justfname(myfile)
gnPos = Ascan(gadatabase, gcname) && Search for company
If gnPos = 0
Do ermsg With gcname
Else
lTableError = .F.
If !Used(myfile)
Use (myfile)Alias (tempter) IN 0
Select (tempter)
logging('Opening '+gcname+' as '+tempter + ' alias ' +Alias())
Endif
If lTableError = .T.
Do ermsg With myfile
Endif
Endif
</code>
my log shows
6:09:36 PM go_openfiles.prg - opening TMG tables
6:09:36 PM Opening MY NEW PROJECT_NPV as TEMP_NPV alias INSTALLS
6:09:37 PM File Open Error!
It must be a simple change to allow each table to be opened.
Can anyone point me in the right direction please?
Thanks in advance.
Colin
In the past my prg has individual openings for each table like
<code>
If !Used(cMyTableName14)
Use (cMyTableName14)Alias TEMP_NPV In 0 Excl
If lTableError = .T.
Do ermsg With 'TEMP_NPV'
Endif
Endif
</code>
where cMyTableName14 is the full file path
However if one of the required tables is absent I get an 'open' error.
So I decided to test for that - function file(cTable) let me down so I used ADIR()
INSTALLS is already open
My calling command is
Do tbl_opening With cMyTableName14,'TEMP_NPV'
my opening routine is
<code>
Procedure tbl_opening
Parameters myfile,tempter
Local gnPos,gcname
**** was using if file(myfile)
Adir(gadatabase, '*.dbf')
gcname=Justfname(myfile)
gnPos = Ascan(gadatabase, gcname) && Search for company
If gnPos = 0
Do ermsg With gcname
Else
lTableError = .F.
If !Used(myfile)
Use (myfile)Alias (tempter) IN 0
Select (tempter)
logging('Opening '+gcname+' as '+tempter + ' alias ' +Alias())
Endif
If lTableError = .T.
Do ermsg With myfile
Endif
Endif
</code>
my log shows
6:09:36 PM go_openfiles.prg - opening TMG tables
6:09:36 PM Opening MY NEW PROJECT_NPV as TEMP_NPV alias INSTALLS
6:09:37 PM File Open Error!
It must be a simple change to allow each table to be opened.
Can anyone point me in the right direction please?
Thanks in advance.
Colin