Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Safe Table Opening Code -How's This?
Message
De
26/10/2001 11:47:19
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00573683
Message ID:
00573688
Vues:
17
What sort of safety do you want?

In general, if you see that you need to do the same thing over and over again, it seems a good idea to create a function or method, as you did here.

If you use an object instead, you can save yourself the trouble of closing the table in code: the table is closed in the class'es Destroy() event. As soon as the object variable gets out of scope, Destroy() fires!

However, there is no need to close tables if you use the table in a form with a private DataEnvironment.

Hilmar.

>
>
>
>Function TOpen
>Parameters cTable,nBuffering,cAlias
>nPrevArea = Select()
>If !Used(JustStem(JustFName(cTable)))
>Use (cTable) in 0 Exclusive Order Alias (cAlias)
>EndIf
>Select (cAlias)
>On Error *
>TableRevert(.t.)
>On Error
>If VarType(nBuffering)="N"
>CursorSetProp("Buffering",nBuffering)
>Wait Window "Table " + cTable + "open in work area " + ;
>Alltrim(Str(Select())) + Chr(13)+Chr(10)+ " BUFFERING " + ;
>Alltrim(Str(nBuffering)) at 2,2
>Select (nPrevArea)
>Else
>CursorSetProp("Buffering",1)
>Wait Window "Table " + cTable + "open in work area " + ;
>Alltrim(Str(Select())) + Chr(13)+Chr(10)+ " NO BUFFERING "  at 2,2
>Select (nPrevArea)
>EndIf
>EndFunc
>
>
>Function VOpen
>Parameters cView,nBuffering,cAlias
>nPrevArea = Select()
>If !Used(cView)
>Use (cView) in 0 NoData Shared Order Alias (cAlias)
>EndIf
>Select (cView)
>On Error *
>TableRevert(.t.)
>On Error
>If nBuffering = 3
>CursorSetProp("Buffering",nBuffering)
>Wait Window "View " + cView + "open in work area " + ;
>Alltrim(Str(Select())) + Chr(13)+Chr(10)+ " ROW BUFFERING " + ;
>Alltrim(Str(nBuffering)) at 2,2
>Select (nPrevArea)
>Else
>CursorSetProp("Buffering",5)
>Wait Window "View " + cView + "open in work area " + ;
>Alltrim(Str(Select())) + Chr(13)+Chr(10)+" TABLE BUFFERING "  at 2,2
>Select (nPrevArea)
>EndIf
>EndFunc
>
>Suggestions wanted. This is for a single-user, all-local "exclusive use" app.
>
>Thanks.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform