Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Global mem vars -> global application properties?
Message
De
10/07/2001 21:57:24
Cindy Winegarden
Duke University Medical Center
Durham, Caroline du Nord, États-Unis
 
 
À
10/07/2001 12:44:03
Nancy Folsom
Pixel Dust Industries
Washington, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00528711
Message ID:
00529016
Vues:
18
>>I am working with an application that use global variables, i.e. public variables defined in the main program. I would like to replace them with equivalent application specific properties, i.e. properties that can be used anywhere in the application. Values for the properties would come from a table.
>>
>>Several examples.
>>1, Name of current user, security level, etc.
>>2. headings for reports, forms, etc.
>>
>>Questions
>>1. Is it possible?
>>2. If so how? Please supply sample code snippets.
>
>I suspect I'm missing something obvious. If you want to continue to use your global variables, then you'd simply
>
>USE yourSettingsTable
>STORE TheReleventFields TO TheReleventPublicVariables
>
>Do I misunderstand your question?

Claude,

To go a little further with what Nancy said, any variable initialized in the Main program is seen throughout the application by default, and it need not be specified as "global."

Some developers use an Application Object (oApp) which holds all the "variables" as properties. You could initialize the oApp in the Main program and when the user identifies himself, pick up the properties and assign them to oApp.

In the login form you'd have something like
SELECT UserTable
LOCATE FOR UserTable.UserID = frmLogin.txtUserID.VALUE
IF UserTable.Password <> frmLogin.txtPassword.VALUE
    *!* Exit app
ENDIF
*!* Good to go
oApp.CurrentUser = UserTable.UserID
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform