Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Replace code in Form with Biz Method
Message
From
24/09/2019 16:28:32
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01671085
Message ID:
01671094
Views:
73
>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.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform