Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to call Object.Method from On Selection Bar command?
Message
De
02/01/2000 11:26:49
 
 
À
02/01/2000 07:53:55
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00311323
Message ID:
00311362
Vues:
18
>Hi,
> I have bar of menu that may need to call method from my class. How could I do so if I don know the reference of the object (myvar = createobj("myclass")), however using THIS or any other ways to reference?
>
>e.g.
>
>myclass.mymethod1
>
>DEFINE BAR 1 OF mypopup PROMPT "MyMethod"
>ON SELECTION BAR 1 of mypopup **CALL MYCLASS.MYMETHOD2**
>
>
>Thank you

It can't really be done in a one line command, you will have to create a procedure to execute the method.
ON SELECTION BAR 1 of mypopup myBar1Procedure
Is the method to be called is not dependent on the current state of properties in the object:
procedure myBar1Procedure
  with newobject("myclass", "myclasslib")
    .myMethod()
  endwith
endproc
Otherwise:
procedure myBar1Procedure

  if vartype( oExternalReference ) != 'O'
    * either throw an error or initialize the oExternalReference at this point
  endif
  oExternalReference.myMethod()
endproc
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform