Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Public variables VS objects
Message
De
04/06/2003 05:29:19
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Divers
Thread ID:
00795846
Message ID:
00796037
Vues:
16
This message has been marked as a message which has helped to the initial question of the thread.
>Hi!
>
>I have an old application where I define a lot of public variables in the main program. So I can use it in all program. I'm explain better using just seven parameters, but, in pratice, I have hundreds of them...
>
>
>Public LicenciadoNome, LicenciadoCNPJ, EmpresaNome, EmpresaCNPJ, Programa, Versao, DataExpiracao
>m.LicenciadoNome = "Qualquer Um"
>m.LIcenciadoCNPJ = "Qualquer Outro"
>m.EmpresaNome = "Rodolfo"
>m.EmrpesaCNPJ = "111.11.11.1.1"
>m.Programa = "Super Programa"
>m.Versao = "1.0"
>m.DataExpiracao = {}
>
>
>Now I'm updating my framework and I'd like to work just with objects... So, I think something like that:
>
>Public oObj
>oObj = CreateObject("Empty")
>AddProperty(oObj,"Licenciado",CreateObject("Empty"))
>   AddProperty(oObj.Licenciado,"Nome","Qualquer Um")
>   AddProperty(oObj.Licenciado,"CNPJ","Qualquer Outro")
>AddProperty(oObj,"Empresa",CreateObject("Empty"))
>   AddProperty(oObj.Empresa,"Nome","Rodolfo")
>   AddProperty(oObj.Empresa,"CNPJ","111.11.11.1.1")
>AddProperty(oObj,"Programa",CreateObject("Empty"))
>   AddProperty(oObj.Programa,"Nome","Super Programa")
>   AddProperty(oObj.Programa,"Versao","1.0")
>   AddProperty(oObj.Programa,"DataExiracao",{})
>
>
>The code above is typed in the main program and creates an object that includes all variables in just one (and organized) object...
>
>Some idea and comments about this solution? .. .Suggestions?
>
>TIA

Rodolfo,
Nice leap :)
One suggestion. Probably these values are filled initially from a table, no?
If from a table (Nome,CNPJ .. sounded to be fieldnames):
scatter name ...
might be a shorcut. ie:
USE orders ORDER tag cust_id
oObj = CREATEOBJECT('empty')
lcCustID = ' '
SCAN
 IF cust_id # lcCustID
    lcCustID = cust_id
    AddProperty(oObj,TRIM(cust_id),CreateObject("Empty"))
 ENDIF
 AddProperty(eval('oObj.'+TRIM(cust_id)),;
   'O'-ALLTRIM(order_id),CreateObject("Empty"))
 SCATTER NAME ('oObj.'+cust_id-'.O'-ALLTRIM(order_id))
endscan
PS: For others who might look into. VFP8 and up specific code.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform