Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Information about all tables in dbc
Message
 
 
À
22/09/2004 02:48:53
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00944853
Message ID:
00945020
Vues:
20
>Dear Nadya
>
>I am unable to write codes to get task.
>So you are requested to please write some codes for me.
>
>Thanks in advance

Hi Tariq,

Ok, from the top of my head (not tested):
create cursor curAllDBCTables (TablePath M, TableName C (40), Records I, Size I, Modify D)
Close database
open database d:\cotton\tables\weight.dbc
local lnI, lnTables
lnTables = ADBOBJECTS(laTables, "Table")
local lcSetCompatible
lcSetCompatible = set ("compatible")
set compatible on && See comments to fsize() function 
for lnI = 1 to m.lnTables
*  I hope to find a way to obtain the info without opening the table
* So the code bellow would be modified
* but for now I'm using this method
* OpenTble is my custom function around USE command
* The code will be provided bellow
 if OpenTble(laTables[m.lnI],"CurrentTable") 
    select CurrentTable
    insert into curALLDBCTables (justpath(dbf()), laTables[m.lnI], reccount(), fsize(dbf()),  lupdate())
   use in CurrentTable && close this table
  else
     = messagebox   ("Problem with " + laTables [m.lnI])
  endif
next
* Now restore set compatible status
if m.lcSetCompatible <>"ON"
   set compatible &lcSetCompatible
endif
Here is the code for OpenTble:
********************************************************************
*  Description.......: OpenTble && Opens the passed table
*  Calling Samples...: OpenTble('TranMstr','WorkFile')
*  Parameter List....: tcTable, tcAlias, tcMode, tcTagOrder, tnBufferMode
*  Created by........:
*  Modified by.......: Nadya Nosonovsky 05/01/2001 11:34:13 AM
********************************************************************
function OpenTble && Opens, but doesn't select a table
lparameters tcTable, tcAlias, tcMode, tcTagOrder, tnBufferMode
* tcTable - required: name of table to open (with or without full path)
* tcAlias - optional: alias name, if different from tcTable
* tcMode - optional:  mode in which table should be opened, like shared noupdate
* tcTagOrder - optional: Tag name
* tnBufferMode - optional: Set buffer mode
local lcTableName, lnPos, llDBCPrefix, lcDBCName, lcPath
* Check parameters first
if vartype(m.tcTable)<>'C' or empty(m.tcTable)
* First parameter is required
	return .f.
endif
lnPos=rat('!',m.tcTable)
if m.lnPos>0 && DataBase Name was specified && example: Support!PostOff
	lcTableName=juststem(substr(m.tcTable,m.lnPos+1)) && PostOff
	lcDBCName=upper(left(m.tcTable,m.lnPos-1)) && DBC Name
	llDBCPrefix=.t.
else
	lcTableName=m.tcTable
endif
lcPath = justpath(m.tcTable)
if vartype(m.tcAlias)<>'C' or empty(m.tcAlias)
	tcAlias=juststem(m.lcTableName)
endif

if vartype(m.tcMode)<>'C' or empty(m.tcMode)
	tcMode='shared'
endif
local lcCheckFile
if empty(justext(m.lcTableName))
	lcCheckFile=forceext(m.lcTableName,"dbf")
else
	lcCheckFile=m.lcTableName
endif
if !file(m.lcCheckFile)  && File doesn't exist
	=messagebox(m.tcTable +' does not exist!. Can not proceed...',48,'Error')
	return .f.
endif
local lnOldSelect
lnOldSelect=select()
if !used(m.tcAlias) or ; && Alias is not already in use or
	(m.llDBCPrefix and not juststem(cursorgetprop("DATABASE",m.tcAlias))==m.lcDBCName) or ; && it's not the same database
	(!empty(m.lcPath) and m.lcPath<>justpath(dbf(m.tcAlias)))
	local lcOldError, lnErr, lcOldSetExclusive
	use in select(m.tcAlias) && Close table && Nadya Nosonovsky 11/20/2001 02:58:33 PM allways
	lnErr=0
	lcOldError=on('error') && Save current Error Handler
	lcOldSetExclusive=set('exclusive') && Save current exclusive status
	set exclusive off && This should be always set this way
	on error lnErr=error()
	use (m.tcTable) again &tcMode in 0 alias (m.tcAlias)
	on error &lcOldError && Restore previous Error Handler
	if m.lcOldSetExclusive='ON'
		set exclusive on && Restore it back to original settings
	endif
	do case
	case m.lnErr=0 && Everything is OK
	case m.lnErr=1705  && File Access is denied
		=messagebox(m.tcTable +' is opened by another user. Can not proceed...',48,'Error '+transform(m.lnErr))
		return .f. && Table could not be opened (already used exclusively)
	otherwise && Another error
		=messagebox(m.tcTable+' could not be opened!',48,'Error '+transform(m.lnErr))
		return .f.
	endcase
endif
select (m.tcAlias) && If it's here, everything is all right
if not empty(m.tcTagOrder) and vartype(m.tcTagOrder)='C' and tagno(m.tcTagOrder)>0
	set order to tag (m.tcTagOrder) in (m.tcAlias)
endif
if vartype(m.tnBufferMode)='N' and between(m.tnBufferMode,1,5)
	set multilocks on
	=cursorsetprop('Buffering',m.tnBufferMode) && Note, we can not set buffering mode less than 3 on a view - no check for this
endif
select (m.lnOldSelect) && Return back to the original area
return .t.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform