Reputation: 205
I have a script below under a datawindow's buttonclicked
event. My problem is how will I call the specific button from other event like parent window post_open
event.
In windows post_open
event I have the script but returns Bad Argument List For Function: buttonclicked
message when I compile. How can I correct this compilation error?
dw_Command.Event buttonclicked('b_read')
DWO: Datawindow
Event: buttonclicked
CHOOSE CASE Lower(dwo.Name)
CASE 'b_read'
SetPointer(Hourglass!)
idt_ServerDate = gnv_app.of_getServerDate( )
of_getInventoryAdvice( )
CASE 'b_exit'
MessageBox('','Close')
Close(Parent)
END CHOOSE
Upvotes: 2
Views: 8541
Reputation: 6215
The correct answer to the asked question has been given, but I'm going to propose a contrarian point of view: that you should (virtually) never do what you're asking. When you get functionality implemented in a system event that needs to be called from another system event, you should probably break that functionality into a separate custom user event (or function) and call it from both places. Why?
At one point, I'm sure it seemed easier to just call ButtonClicked. I'm betting you're already teetering on the edge of that decision, and with a little imagination, I'm hoping you'll split apart the script into something more modular. Never regretted breaking something apart...
Good luck,
Terry.
Upvotes: 4
Reputation: 11465
Bad Argument List For Function: buttonclicked
That message is telling you that you are not passing the correct type and /or number of arguments to the function (or event).
The ButtonClicked
event is expecting 3 arguments that you must emulate if you want to call it yourself:
row
a row number where the button has been calledReturnCode
a long value that is returned by the action performed by the buttondwo
a datawindow object. It is a a reference to the control that was "clicked" by the mouse pointer, you can pass a dw.object.name_of_your_button
You could try with the following:
long ll_arc
dw_Command.event buttonclicked( dw_Command.getrow(), ll_arc, dw_Command.object.b_read )
Upvotes: 2