[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 516
  • Last Modified:

poerbuilder cancel query

i want to make the combination of keys shift+f1 to act as cancel-query keystroke. if it is pressed it should break the query that is being executed and return control to the main program.

How can i do it?

since i am new to powerbuilder i would appreciate the answer to be as clear as possible

0
basilhs_s
Asked:
basilhs_s
1 Solution
 
diasroshanCommented:
Hi,

I am assuming u r retrieving the query in a datawindow.
dwcontrol.DBCancel ( ) is wat ur looking for.
Check PB Help for DBCancel.

You would need to use datawindow events RetrieveStart and RetrieveRow

Below is the PB Help example for DBCancel which is pretty detailed.

In this example, the menu bar for an MDI application has menu items for starting and canceling a retrieval. When the user cancels the retrieval, a user function calls DBCancel and sets a boolean instance variable to Get/SetSeriesStyle and Get/SetDataStyle. The RetrieveStart and RetrieveRow events check this variable and return the appropriate value.
In this hypothetical application, the user starts a retrieval by selecting Retrieve from a menu. The script for the Retrieve menu item calls a user function for the window:

w_async1.wf_retrieve()

The wf_retrieve function sets the Async DBParm for asynchronous processing and starts the retrieval. Because Async is set to 1, the user can select the Cancel menu item at any time, even before the first row is retrieved. (In your own application, you would include error handling to make sure Retrieve returned successfully.)

long rc
ib_cancel = false
SQLCA.DBParm = 'Async = 1'
rc = dw_1.Retrieve()

The user can stop the retrieval by selecting Cancel from the menu. The script for the Cancel menu item reads:

w_async1.wf_cancel()

The user function wf_cancel for the window w_async1 calls DBCancel and sets a flag indicating that the retrieval is canceled. Other events for the DataWindow will check this flag and abort the retrieval too. The variable ib_cancel is an instance variable for the window:

ib_cancel = true
dw_1.DBCancel()

Scripts for the RetrieveStart and RetrieveRow events both check the ib_cancel instance variable and, if it is true, stop the retrieval by returning a value of 1. In order to cancel the retrieval, some code or comment in the script for the RetrieveRow event is required:

IF ib_cancel = true THEN
        RETURN 1
END IF

//Example ends here

As far as using a combination of Shift + F1 goes,
to keep it simple, if ur using a menu, u can have a menu item and assign the shortcut key property of that menu item to Shift + F1 and keep it invisible if u want.

Else,
Check PB Help for KeyDown event (DataWindows)
u will have to create a new event in ur Datawindow with event id pbm_dwnkey
say ue_keydnw
Now,
IF keyflags = 1 THEN
      If key = KeyF1! Then      
                    //ur code here
                end if
End If

Cheers,
Rosh
0
 
basilhs_sAuthor Commented:
perfect analysis for a novice to powerbuilder like me. thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now