Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Replace code in Form with Biz Method
Message
 
 
À
24/09/2019 16:28:32
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01671085
Message ID:
01671095
Vues:
43
>>Hi,
>>
>>I am working on refactoring the following code. Currently the code (pretty long, about 2000 lines) is executed in a method of a button click. And I am "moving" this code to a method of a Biz class.
>>The form, on which the button reside, has text box controls that shows the progress. E.g. "Processing records number # ...", "Order Number: " + OrderNo. So, that the user knows that something is going one.
>>The BIZ method code has to update the form controls (the progress above). Here is the segment of the current code that shows the progress:
>>
>>	thisform.wo_count.value = alltrim(str(nCountOrders))
>>	thisform.wo_number.value = alltrim(str( CUR_PM_WOS.WO_NUMBER )	)		
>>	thisform.equipment_id.Value = CUR_PM_WOS.EQUIP_ID
>>	Thisform.Draw
>>
>>	DOEVENTS 
>>
>>
>>How would you suggest to update the Form controls from the BIZ object code?
>>
>>TIA
>>
>>UPDATE. One idea I have is to pass the form reference to the BIZ method. But it seems to be a kludge.
>>
>>UPDATE 2. Another question is how to deal with a user interrupting the process. The form has Cancel button which set the form property lExit to .T. And the Process code checks for this value. Of course, when the Process code runs in a Biz method, the form property is out of scope. Unless, again, I pass the form reference to the BIZ method. But I am thinking/looking for a better solution/approach
>
>You've already figured out the answer - pass the form as an object reference to the method e.g. LPARAMETERS toForm, ... . That solves the Cancel issue; where it currently checks for ThisForm.lExit = .T., instead it checks for m.toForm.lExit = .T.

Yes, It does seem to work - passing the form as an object. However, when I click on the Cancel button (where for testing I put Messagebox), the click fires only after the entire procedure is done. That is, I see the messagebox() after the process is complete. And I do have DOEVENTS in several places in the code. But it does not seem to do anything.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform