Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calling Procedure in a Program (.PRG)
Message
De
23/10/2018 18:26:24
Mike Yearwood
Toronto, Ontario, Canada
 
 
À
23/10/2018 14:50:32
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01662746
Message ID:
01662759
Vues:
51
>>>Respected all,
>>>
>>>I have a .prg File , in which I have sequence of procedures I have to carry on one by one to get my desired results. Till Now I have kept all procedures in sequence of one another, but since there are many such procedure (Steps) involved and my .prg has become big and less understandable easily.
>>>
>>>I am thinking to put procedures at the end of .prg and Call that procedure step by step so that it may be easily comprehended.
>>>
>>>For this I have kept one of such Procedure under PROCEDURE LEFTBOX at the end of my .prg file and calling that procedure using DO Leftbox.
>>>
>>>The procedure is generating value for it but when it comes back to the main routine it gives error as variable Boxstartrow not found.
>>>
>>>If I declare Boxstartrow as PUBLIC, it works fine.
>>>
>>>Will I have to declare all such variables as Public, which I am intending to use in procedure or there is some other way also ?
>>
>>Don't ever use public variables. They cause far more problems than they solve.
>>
>>It's not entirely clear what you're doing here, but I think the answer is that you need to declare the variables you need in the main program and then pass them as parameters to the routines that use them. So you'd have something like:
>>
>>
>>LOCAL BOXSTARTCOLUMN, BOXENDCOLUMN, BOXSTARTROW, BOXENDROW, BOXCOLUMNRANGE
>>* Add other declarations for variables you need in other of the routines
>>
>>DO LeftBox WITH BOXSTARTCOLUMN, BOXENDCOLUMN, BOXSTARTROW, BOXENDROW, BOXCOLUMNRANGE
>>
>>DO abc with ...
>>
>>DO xyz with ...
>>
>>
>>You'll also have to modify the routines themselves to accept the parameters, like this:
>>
>>
>>PROCEDURE LeftBox
>>LPARAMETERS BOXSTARTCOLUMN, BOXENDCOLUMN, BOXSTARTROW, BOXENDROW, BOXCOLUMNRANGE
>> * rest of the code
>>
>>
>>
>>All that said, this sounds like a candidate for defining a class, where you can make all those variables into properties and then just reference this using This.Whatever.
>>
>>Tamar
>
>*********
>Thank You Madam, it worked Fine. Thanks for Guiding.
>Regards,
>Harsh

It's better not to arbitrarily store unrelated blocks of code in a single procedure, nor unrelated classes in a single classlib.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform