Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Passing parameters to a function
Message
De
05/12/2008 05:07:05
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01365569
Message ID:
01365609
Vues:
16
>Hi,
>
>I have a generic function called something like OpenForm(). The function currently receives 2 parameters tcClassName, and tcClassLib. Then function opens a form as the following:
>
>
>objForm = NEWOBJECT( tcClassName, tcClassLib )
>
>
>Now I want to add some parameters to the function OpenForm() so that they would be passed to NEWOBJECT(). But it has to be generic since in some places no parameters would be required. And in some others it will be 1 parameters, 2, etc. Say, I want to limit to 3 parameters. So I will add 3 more parameters to the function OpenForm(). But not all of them should be passed to the NEWOBJECT(). Short of creating DO CASE with a CASE depending on how many parameters were received (using PCOUNT())by OpenForm(), is there a way to do it generically?
>
>Thank you in advance for any suggestions.

Your method looks like:
procedure OpenForm( m.tcClassName, m.tcClasslib, m.tuParm1, m.tuParm2, m.tuParm3 )
local lnParameters, objForm
lnParameters = pcount()
do case
  case m.lnParameters = 0
    objForm = NEWOBJECT( m.tcClassName, m.tcClassLib)
  case m.lnParameters = 1
    objForm = NEWOBJECT( m.tcClassName, m.tcClassLib, '', m.tuParm1)
  case m.lnParameters = 2
    objForm = NEWOBJECT( m.tcClassName, m.tcClassLib, '', m.tuParm1, m.tuParm2)
  case m.lnParameters = 3
    objForm = NEWOBJECT( m.tcClassName, m.tcClassLib, '', m.tuParm1, m.tuParm2, m.tuParm3 )
endcase
Where is the problem?

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