General information
Category:
Coding, syntax & commands
I use the following code is a prg that is called by my error handler prg to obtain among other things a list of all open tables in all data sessions.
** Display Tables open in datasession
local mTableArray,mTableCount,msetdatasession,mdatasessionlist
Dime mTableArray[1,2]
AUSED(mTableArray)
= strtofile(space(10)+chr(13)+chr(10),datadir+'Error.txt',.t.)
= strtofile("Tables open in current DataSession ("+alltrim(str(set('datasession')))+"): "+chr(13) ;
+chr(10),datadir+'Error.txt',.t.)
= strtofile("Table Alias Record Count Filename"+chr(13)+chr(10),datadir+'Error.txt',.t.)
For mTableCount = 1 to ALen(mTableArray,1)
if !empty( mTableArray[mTableCount,1] )
= strtofile(padr(mTableArray[mTableCount,1],16)+str(recno(mTableArray[mTableCount,1]),8)+' ' ;
+str(reccount(mTableArray[mTableCount,1]),8)+' '+dbf(mTableArray[mTableCount,1])+chr(13) ;
+chr(10),datadir+'Error.txt',.t.)
endif
EndFor
mxlinesadded = .t.
msetdatasession = alltrim(str(set('datasession')))
mdatasessionlist = alltrim(str(set('datasession')))
if _Screen.FormCount > 0
for fc = 1 to _Screen.FormCount
if type('_Screen.Forms(fc)') = 'O'
if wexist(_Screen.Forms(fc).name)
if at(alltrim(str(_Screen.Forms(fc).datasessionid)),mdatasessionlist) = 0
if AUSED(mTableArray,_Screen.Forms(fc).datasessionid) > 0
mdatasessionlist = mdatasessionlist + ':' + alltrim(str(_Screen.Forms(fc).datasessionid))
set datasession to (_Screen.Forms(fc).datasessionid)
= strtofile(space(10)+chr(13)+chr(10),datadir+'Error.txt',.t.)
= strtofile("Tables open in DataSession ("+alltrim(str(_Screen.Forms(fc).datasessionid)) ;
+"): "+_Screen.Forms(fc).name+chr(13)+chr(10),datadir+'Error.txt',.t.) = strtofile("Table Alias Record Count Filename"+chr(13) ;
+chr(10),datadir+'Error.txt',.t.)
For mTableCount = 1 to ALen(mTableArray,1)
if !empty( mTableArray[mTableCount,1] )
= strtofile(padr(mTableArray[mTableCount,1],16) ;
+str(recno(mTableArray[mTableCount,1]),8) ;
+' '+str(reccount(mTableArray[mTableCount,1]),8)+' ' ;
+dbf(mTableArray[mTableCount,1])+chr(13)+chr(10),datadir+'Error.txt',.t.)
endif
EndFor
endif
endif
endif
endif
endfor
endif
if not empty(msetdatasession)
mcommand = "set datasession to " + msetdatasession
&mcommand
endif
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only