Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Scanning through objects to assign property values
Message
De
17/05/2001 16:43:52
David Fluker
NGIT - Centers For Disease Control
Decatur, Georgie, États-Unis
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00508436
Message ID:
00508514
Vues:
18
>>>Is there a way to assign property values to a group of objects if there is not a value already asssigned? I'm looking to set all the HelpContextID properties for objects on a page (form, pageframe, whatever...) to a specific value unless they have previously been assigned in development. I'm trying to think of a way to use the SetAll method to handle this... Thanks!
>>>
>>>Regards, Renoir
>>
>>Here is a sample assign method that will do what you want.
>>This code makes two assumptions:
>>1. If you don't set the HelpContextID it defaults to 0.
>>2. Sometimes you may want SetAll("helpContextID" ##) to really set them all, and other times just the ones that are still the default value.
>>
>>In your base class, create an assign method to HelpContextID and a new property ProtectHelpContextID. The property defaults to .F.
>>
>>This code in the new assign method will do the job
>>
>>LPARAMETERS vNewVal
>>*: Change property to new value if permitted or if default value
>>IF (This.ProtectHelpContextID = .F.) OR (This.HelpContextID = 0)
>>	THIS.HelpContextID = m.vNewVal
>>ENDIF
>>
>>
>>And use this code to change defaults to 999
>>
form.SetAll("ProtectHelpContextID",.T.)
>>form.SetAll("HelpContextID",999)
>>form.SetAll("ProtectHelpContextID",.F.)
>>
>
>Hi David,
>
>Your example first sets ProtectHelpContextID to .t., then according to the method you wrote, it would not assign 999 to HelpContextID.
>
> Actually, this is exactly what I meant, when wrote a message to Renoir. We probably don't need the property ProtectHelpContextID, though it may be a good idea to have it.

Hi Nadya,

The assign method will update HelpContextID if ProtectHelpContextID = .F. OR If HelpContextID = 0. So...
If ProtectHelpContextID is .F. all objects will update.
If ProtectHelpContextID = .T. only those with a value of 0 will update.
ProtectHelpContextID's default value of .F. allows SETALL("HelpCOntextID",###) work normally, setting all the objects to the new value.

Putting the logic in one IF-THEN statement makes it difficult to read. I should have split it into two IF-THEN statements like this.
IF ProtectHelpContextID = .F.
   THIS.HelpContextID = m.vNewVal
ELSE 
   IF HelpContextID = 0
      THIS.HelpContextID = m.vNewVal
   ENDIF
ENDIF
David.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform