Can a Procedure Click on Buttons in another Window?

Hi all
I have a program with the following procedure structure:

Capture2

The highlighted procedure “SummaryReport” is routinely called by the Timer event on the Main module, at 10pm. It can also be called by clicking on a button on the main toolbar.

But I would like to include a graph in the report. At the moment I can get the graph manually as follows:

Click on the “Graph” button on the main toolbar. This opens the “GraphWindow” window (shown here). Then I click on the “Today” button to get the data for today (It normally shows yesterday’s data because today’s data is incomplete before 9pm) and then the “Save” button, followed by “Close”.

How would I go about doing this programmatically? I want to include the saved graph in the “report” that gets emailed at 10pm. It’s a text email, not a Clarion report.

All suggestions would be most welcome.
Best wishes
Donn
C11 PE 11.0.13630 with NetTalk 12.45 and CapeSoft Draw 4.33

Instead of thinking of pushing buttons add an OpenAction Parameter to SummaryReport(STRING OpenAction)

In SummaryReport at the end of ThisWindow.Open() or Event:OpenWindow check if Action wants the Report Today thing then run the Today code, Save Code and Close the Window:

IF OpenAction='ReportToday' THEN 
    DO TodayRtn
    DO SaveRtn
    ThisWindow.Kill() or POST(EVENT:CloseWindow)
END 

Since you probably START() this Procedure elsewhere that code will need to change to Pass blank START(SummaryReport,,'') because a Started procedure cannot have <Omittable Parms>.

An alternative is a shim for START that calls the one with OpenAction. Rename SummaryReport() to SummaryReportWithParms(STRING OpenAction), then make a simple Source “shim” named SummaryReport() that calls SummaryReportWithParms('NothingSpecial'). All the STARTs can call that without passing the Action so no changes. I’ll do that when its exported from a DLL and there are a bunch of callers.

To answer your original question … To click on Buttons in another Window I would use Event:Notify to send the Window a special message and that Event:Notify code would click the buttons based on the NOTIFICATION() parameters.

2 Likes

I’m with Carl. I’d handle this by passing parameters to do the appropriate action. That may include passing parameters to any sub-procedures as well.

Thanks guys. I got the graph inserted in the report, albeit in a different way to what I expected.

I got a bit tied up in knots here. If I START(GraphWindow) then nothing happens until the calling procedure finishes, and only then the GraphWindow opens and does its thing.

I worked around it, but I’m not understanding something obvious.

and only then the GraphWindow opens and does its thing.

Donn - look up RESUME in the help.

jf

1 Like

For the Report you do Not want to Start(GraphWindow), you just want to call it passing the action GraphWindow('ReportToday'). When it finished it will return to the Report and the Graph should have been made by the Action=‘ReportToday’ code.

If you did RESUME( Start(GraphWindow) ) then the Graph Window code would run right away. But then you have 2 threads running … Back in the Report procedure Thread the code after Resume(Start()) would soon get a time slice and run, probably certainly before the GraphWindow finished. You would need synchronization to make that work, but you don’t need it multi-threaded. Just call Graph don’t Start().

1 Like