Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Exclusive use of table
Message
 
 
À
17/05/2001 03:25:09
Jimi Lee
Pop Electronic Products Ltd.
Hong Kong, Hong Kong
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00508197
Message ID:
00508265
Vues:
23
This message has been marked as a message which has helped to the initial question of the thread.
>hey Gavin,
>
>Yeah I did it! Thank a lot! :D
>
>btw, how did you post the source code, such that the back color is changed?

Put your code in < pre > < /pre > tags (without spaces, of course).

BTW, here is another example of Open Table UDF:
********************************************************************
*  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 didn't select a table
lparameters tcTable, tcAlias, tcMode, tcTagOrder, tnBufferMode
*=messagebox( "tcTable "+tcTable+ chr(13)+"tcTagOrder "+iif(!empty(tcTagOrder),tcTagOrder,""))
* 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
* Check parameters first
if vartype(m.tcTable)<>'C' or empty(m.tcTable)
* First parameter is required
     return .f.
else
     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
endif
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) && it's not the same database
     local lcOldError, lnErr, lcOldSetExclusive
     use in select(m.tcAlias) && Close table
     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
     if m.lnErr<>0 && Error occurs
          if m.lnErr=1705  && File Access is denied
               =messagebox(m.tcTable +' is opened exclusively by another user. Can not proceed...',48,'Error '+transform(m.lnErr))
               return .f. && Table could not be opened (already used exclusively)
          else && Another error
               =messagebox(m.tcTable+' could not be opened!',48,'Error '+transform(m.lnErr))
               return .f.
          endif
     endif
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.
Color formatting is based of mhHtmlCode utility available in the Downloads section.
If it's not broken, fix it until it is.


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

Click here to load this message in the networking platform