Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to set a variable to a property?
Message
De
01/04/2021 10:49:25
Mike Yearwood
Toronto, Ontario, Canada
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
01679404
Message ID:
01679433
Vues:
39
>>>The class is in the Visual Class Library (*.VCX). Let me provide more details:
>>>I have a form class (equipment) in a library equip.vcx
>>>There is a BIZ class dropped on this form (BIZ class is EQ_BIZ).
>>>The BIZ class EQ_BIZ has a property PRE_FILTER.
>>>I am trying to set the value of PRE_FILTER to some public variable cTest. The public variable cTest is declared in the LOAD of the EQUIPMENT form; therefore, it is in the scope when the EQ_BIZ is initialized.
>>>I am trying to figure out how to assign the value of the variable cTest to the property EQ_BIZ.PRE_FILTER.
>>>I tried:
>>>(at design time): setting the value of EQ_BIZ.PRE_FILTER = cTest This does not work.
>>
>>Of course it doesn't work, the variable doesn't exist at design time. Or even if it did, there's no guarantee that it'd have the right value.
>>
>>>I also tried to use a macro, Example: EQ_BIZ.PRE_FILTER = &cTest. This does not work.
>>
>>At design time? No way, same as above.
>>
>>You may try to give it a value of =(cTest), the equal sign should denote an eval() of the parenthesized value, that may work. I didn't use that more than just a few times, so in my experience it's something that might work. Actually, what I found working is a value of =SomeFunction() in the PEM editor, which gets evaluated when the object instantiates. That was just about the only way I found to instantiate a bizobject _before_ the object instantiates, by having a function which would return the bizobject - and mind you, I needed that to work on a container in a pageframe, no .load() method there.
>>
>>Of course, there's the also the easy way... somewhere in the .load() of your form, just have a
>>this.eq_biz.pre_filter=m.cTest
>>Or do it in the .init() of the bizobject itself.
>
>Starting from the last part of your message. Trying to set the value in the LOAD is where I started. But the error message (at run-time) is "Unknown member EQ_BIZ". So even thought the intellisense (at design time) in LOAD method shows the EQ_BIZ and all it's properties, at run-time it won't work. This would be the simplest solution. Here is the code in the LOAD method that I tried (let me know if you see anything missing there):
>
>thisform.eq_biz.pre_filter = "in_server = 'Y'"
>
>
>I think I will try your approach with =someFunction().
>
>Thank you.

In the load of the form, the form itself does not yet exist. eq_biz is not on the form's parent class right? You would be better off doing this in the init of "thisform" because by then - according to Drew Speedie's LISAG, the eq_biz should have loaded.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform