0
votes

My situation is as below:

We are using PFC in our application. What all I want to do it, when we click on button (Inherited from object - writing code on parent button object) it should capture row count from the DataWindow which is exists on the same window.

I am storing window, DataWindow and button name in database.

window name- w_emp

DataWindow name - d_emp

button name - b_emp

so when user click on button, I am retrieving those data and check if it's same window, data window and button exists which I am looking for.

If it is YES then I want to get row count of DataWindow on button clicked event.

BUT....

I don't want to use any hard coded logic for that like...

If windowname = 'w_emp' then     
w_emp.d_emp.rowcount() 
Elseif...
End if...

I want something like, where I can do the same thing with some line of code without doing if...else or case statement where I have to check for multiple conditions.

I am able to access window and data window name at button level.


string      ls_window 
string      ls_datawindow 

datawindow      ld_test 

select window_name, datawindow_name into ls_window, ls_datawindow from table_name where button_name = 'b_emp'; 

ld_test.dataobject = parent.ls_datawindow // It is giving an error 

I want to get DataWindow row count which is coming from database.

Make sure that I want to do at parent level where I can get request from entire application whenever user clicks on button. so I need dynamic logic for the same.

1
Without knowing the error you mention I assume it has to do with the fact that you have not created the datawindow 'ld_test'. To do so you need a ld_test = CREATE datawindow statement. ALSO remember that the datawindow method rowcount tells you the number of records in the primary buffer which may be different than the number of rows retrieved from the database due to filtering, deleterow, and other method calls.Matt Balent
I think there's an easier way to do what you want. What do you want to do with the rowcount? Why does it need to be different depending on the button name and window name?Hugh Brackett

1 Answers

0
votes

What you're trying to do is expecting parent. to evaluate to a control; PowerBuilder doesn't do that. What you can do is cycle through the Control[] array, comparing the ClassName() on each against your string. Depending on how thorough a job you want to do, you'll have to recurse every time you hit a control that is TypeOf() Tab! or UserObject!. (If you have PFC, you have a good example in of control scanning recursion in (pfcapsrv.pbl)pfc_n_cst_luw.of_update ()).

Good luck,

Terry.