advguisample question

1
0
-1
hai experts
i add a datawindow name dw_1 and dataobject = d_test to u_cst_test5 useroject of advguisample.pbl
and created a event closequery and event id pbm_closequery and add following event
dw_1.AcceptText()
IF dw_1.ModifiedCount() > 0 or dw_1.DeletedCount() > 0 THEN
    IF MessageBox("Save Changes", "Would you like to save your changes before you exit the                        window?", Question!, YesNo!, 1) = 1 THEN
        Return 1
    End IF
End IF 
when i run the application and made changes and close the tab without save it closes without executing above code ;does anyone suggest where is the fault and how to correct it?  i debugged but cannot open debug window when i close the tab. i am using Powerbuilder classic 12.5 version
regards
kumar

Question Tags: 

Answers

Roland Smith answered advguisample question

1
0
-1

Closequery is a window event. If you add it to another type of object, it isn't going to be triggered.

ghkumarchd_28597's picture

thank you so much for the information and response sir,

in order to achieve the result i put the following code in uo_tabcontrol tabclosed event of the w_main window


If isvalid( iuo_1) then
   iuo_1.dw_1.AcceptText()
   IF  iuo_1.dw_1.ModifiedCount() > 0 or  iuo_1.dw_1.DeletedCount() > 0 THEN
      IF MessageBox("Save Changes", "Would you like to save your changes before you exit the   window?", Question!, YesNo!, 1) = 1 THEN
         Return 1
     End IF
   End IF 
End if 

when i compile i got error Return expression in subroutine

can you give me a clue about error in above code  or any event i can put the above code?

regards 

Kumar

Govinda Lopez's picture

Hi Kumar,

 

You are returning a value where the subroutine is set as (None)

 

Regards,

Lars Mosegaard's picture

For tab pages you can use the selectionchanging event and return 1 if acceptext() returns -1 or user wants to stay on tab page before closing after your messagebox.

I don't believe there is a built in way of "closing" a tab page like a window has, but if you have a script that closes a tabpage, you need to ask the question beforehand.

You still need the window closequery event script. 

Kevin Ridley answered advguisample question

1
0
-1

Why not trigger your userobject event from the window's closequery event?

ghkumarchd_28597's picture

hai kevin

yes i can trigger userobject event from the window's closequery event, but in advancedgui sample programs, we can close userobject before main window close. then triggering userobject event has no logic. any other possibilities?

regards

kumar

 

Chris Pollach answered advguisample question

1
0
-1

Hi Kumar;

  This example logic has a major flaw in it. The AcceptText () method return code is not checked. If you only update one column and it is in error, then the counts would be zero. The logic flow should be ...

Int  li_rc

li_rc = DC.AcceptText ()

IF  li_rc = -1  THEN

    DC.SetFocus ()

    MessageBox (" Data Errors ", " Please correct " )

    Return -1

else

  IF ModifiedCount > 0 ....

 

HTH

Regards ... Chris