Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do I create an empty class?
Message
De
11/12/2003 12:15:29
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
11/12/2003 11:46:37
Mike Sue-Ping
Cambridge, Ontario, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00858157
Message ID:
00858207
Vues:
21
>>>>>I have a non-visual application object that is based on the Custom VFP baseclass. I want to try to change it to an Empty baseclass since it is supposed to be better for this type of thing.
>>>>>
>>>>>I read in the help file that the latter cannot be done visually, but I could not find an example of how to create an empty class in code.
>>>>>
>>>>>Anyone care to share some sample code on how I go about doing this?
>>>>>
>>>>>TIA
>>>>>
>>>>>Regards,
>>>>>
>>>>>Mike
>>>>
>>>>
>>>>loEmpty = NewObject('myEmpty','myNonVis.prg')
>>>>
>>>>*myNonVis.prg
>>>>define class myEmpty as Empty
>>>>enddefine
>>>>
>>>>Was this what you asked ?
>>>>Cetin
>>>
>>>Hi Cetin,
>>>
>>>Thanks for the response.
>>>
>>>I guess I'll know the answer after I try it <g>.
>>>
>>>Mike
>>
>>You replied before I could update :) To my surprise it didn't work. Wish it was my syntax error.
>>Update: Makes sense when I read the help :
>>"You cannot subclass or add custom methods and events to the Empty class"
>>Cetin
>
>Cetin,
>
>You're correct in that it doesn't work. So now my question is, what is an Empty class good for? Just to store custom properties? I'm assuming that it can do the latter.
>
>Mike

Practically yes. Actually I wanted something like that prior to VFP8. I've a sample (don't remember if I totally wrote it or modified a code as a reply) :
USE orders ORDER tag cust_id

oObj = CREATEOBJECT('empty')
lcCustID = ' '
SCAN
 IF cust_id # lcCustID
 	AddProperty(oObj,TRIM(cust_id),CreateObject("Empty"))
 	lcCustID = cust_id
 ENDIF
 AddProperty(eval('oObj.'+TRIM(cust_id)),;
    'O'-ALLTRIM(order_id),CreateObject("Empty"))
 SCATTER NAME ('oObj.'+cust_id-'.O'-ALLTRIM(order_id))
endscan
*set step on && check oObj in debugger
? AMEMBERS(arr,oObj)
What it basically does is to gather Customer and his orders hierarchically into a single object. This is great power IMHO ie: when you need to transfer customer,orders,orditems etc as a single object to another data session, application etc.

Scatter name is powerfull but the obhject it created doesn't expose an Addproperty() method whilst empty does. Prior to VFP8 I'm creating other ligthweight objects such as line,relation,session to pass parameters 'cargoed' in an object. ie:

loParms = createobject('Empty')
loParms.Addproperty('StartDate', ...)
...
loParms.EndDate = ...
loParms.Country = ...
...
loRetObj = loCusUtils.MyCustomersToFollowup(loParms)

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