Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can I wrap my code (incl.) to cleanup cursors
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 6 SP5
Divers
Thread ID:
01107589
Message ID:
01107616
Vues:
18
>Dear all
>
>I have the following code to call my mover box:
>
*** call the mover form
>IF DoForm("afrmMoverCursorVert", "CA1 OIO Numbers", "crstCA1", 1)
>	*** init for new values
>	THIS.VALUE = curSelected.cOIONo
>
>
>	*** close movers cursors
>	USE IN curAvailable
>	USE IN curSelected
>ENDIF
>
>As you notice that I have to close the cursors, this is a simple logic and I am clearing up there and then, there maybe complicated logic inbetween the mover and closing of the cursor.
>
>Is there any way that this can be may self garbage collecting?

It is hard to say, because I don't know what you have in DoForm() and in the Mover form.
But from that I see you rely on the value of curSelected so you can't close it before you get the value.
You could do something like this:
1. Made Mover form DataSession to be private
2. Open all neccessary tables and cursors there
3. Change DoForm function:
myValue = 0 && [],{} or whatever type you want
DoForm("afrmMoverCursorVert", "CA1 OIO Numbers", "crstCA1", 1,@myValue)

*** 
FUNCTION DoForm(lvFormName,par2, par3, par4, VariableThatWillHoldsReturnedValue)

    IF PCOUNT() < 5
       DO FORM .....
    ELSE
       DO FORM ..... TO VariableThatWillHoldsReturnedValue
    ENDIF

RETURN ....
        

*** then in Mover Form
*** Add a property named ReturnValue
*** Init
USE AllNeccesaryTable
** FillListBox1
** Initialise ReturnValue to empty value of that type you want to return

** Somewhere where the user Selects Save/Return/Choose whatever is it put:
thisform.ReturnValue = curSelected.cOIONo

** In Unload 
RETURN thisform.ReturnValue



*** And then your code will be:
myValue = 0
IF DoForm("afrmMoverCursorVert", "CA1 OIO Numbers", "crstCA1", 1, @myValue)
   *** init for new values
   THIS.VALUE = myValue
>ENDIF
Something like this.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform