Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.
Does Post_Event work?
I am calling post_event(@window,"UPDATE_PAGE"). I am catching the event in my code, but the code that catches the event never runs.
Does POST_EVENT work, or is it an undocumented thing that just doesn't work?
Does POST_EVENT work, or is it an undocumented thing that just doesn't work?
Comments
It must first be explained that UPDATE_PAGE is not a normal event. We would call this a custom event. Custom events must be defined using the Event Designer tool. Did you happen to do that first? If not, where exactly is your code that never runs?
If you did define a custom event then I would ask you to see if Send_Event works instead of Post_Event. If so, I would be really surprised as they both do work just fine. However, there is a unique situation wherein Post_Event can fail as a result of a prior error condition. Restarting OI will fix this.
Does any of this apply to your situation?
yes, post_event does work for a bit, then it stops working. To get it to work again, I have to restart OI. So I must be running into the "unique situation" you referred to. The code that seems to break the post_event changes the VPOSITION property and some of the properties of your (SRP's) tab control:
curr_page = get_property(@window,"VPOSITION") curr_page<1,1> = srch_results_page$ set_property(@window,"VPOSITION",curr_page) Set_Property(@window:".OLE_TAB", "OLE.TabVisible[ALL]", false$) Set_Property(@window:".OLE_TAB", "OLE.TabVisible[":srch_results_page$:"]", true$) Set_Property(@window:".OLE_TAB","OLE.SelectedTab", srch_results_page$)
Also, I have used post_event before, and it's worked no problem. I've never needed to "define" an event. I just do this post_event(@window,"event_name"), and it works. I catch the event in the "commuter routine."
compile function cc_customer_order_search_occ_events(focus, event, param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14, param15) /***************************************************************************** * Copyright (c) 1988-2014 OrYx Technology Pty. Ltd. * CC_CUSTOMER_ORDER_SEARCH_OCC commuter routine * Returns: true (1) if successful (continue event chain), else 0 * Parameters: focus : (@FOCUS) control which fires the event event : (@EVENT) event fired param1, param2... etc : specific to the EVENT type * Modifications: *************************************************************************** 1.0 - 290518 - jg - Creation ***************************************************************************/ * system $Insert app_inserts $insert STDIO.INS declare function get_property,rgb declare subroutine set_property * custom $insert oryx_srp_custom_properties.ins $insert oryx_reference.ins $insert itv_get_product_detail.ins declare subroutine oryxlib_msg, oryxlib_msg_query, oryxlib_msg_error, oryxctl_set, oryxctl_set_grid declare subroutine oryxctl_update, oryxctl_keepfocus, oryx_contextmenu, oryxctl_set_valid, oryxlib_execute_entity declare subroutine oryxctl_insertrow,oryxlib_show_form,oryxctl_disable,oryxctl_setfocus,oryxole_setup_tabcontrol_manual declare function oryxctl_get, oryxlib_assigned, oryxctl_get_grid, oryxlib_open_file, oryxlib_standard_menu declare function oryxlib_popup, oryxctl_modified, oryxlib_popups, oryxlib_read_record, oryxctl_id_exists,oryxref_get_value declare function oryxctl_get_col,oryxlib_get_date_reference,oryxado_select,oryxado_execute,itv_get_product_detail,oryxctl_modified,oryxlib_get_datetime,itv_get_sku_base valid = true$ window = field(focus,'.',1) control = field(focus,'.',2) //change later equ ado_connection_id$ to 'DEV_ADO' equ client$ to 1 ;* TVSN Client equ grd_orders$ to @window:'.GRD_ORDERS' equ date_time_col$ to 1 equ order_no_col$ to 2 equ product_col$ to 3 equ net_value_col$ to 4 equ order_qty_col$ to 5 equ pick_qty_col$ to 6 equ disp_qty_col$ to 7 equ bord_qty_col$ to 8 equ auth_sts_col$ to 9 equ proc_sts_col$ to 10 equ paymnt_sts_col$ to 11 equ actions_col$ to 12 equ today$ to "Today" equ last_30_days$ to "Last 30 Days" equ last_6_months$ to "Last 6 Months" equ this_year$ to "This Year" equ last_2_years$ to "Last 2 Years" equ custom_date$ to "Custom Date" equ default_date$ to last_30_days$ equ stored_proc_date_format$ to "D4/E" equ all_orders_page$ to 1 equ pending_orders_page$ to 2 equ current_orders_page$ to 3 equ held_orders_page$ to 4 equ srch_results_page$ to 5 equ order_srch_type$ to "Order No" equ product_srch_type$ to "Product" equ default_srch_type$ to product_srch_type$ if Get_Property(focus, 'TYPE') = 'EDITTABLE' then currPos = get_property(@window, var_srp_editcell_CURRpos$) column = currPos<1> end else column = '' //locate event in 'OnMouseEnter,OnMouseExit,WINMSG,MOUSEOVER,MOUSEOFF,ACTIVATED,INACTIVATED' using ',' setting pos then return valid ;* when debugging Begin case // form-based events Case control = '' begin case case event = 'CREATE' gosub create CASE event = 'READ' gosub post_read case event = 'WRITE_PRE' gosub pre_write case event = 'WRITE' gosub post_write case event = 'WINMSG' if param2 = WM_RBUTTONDOWN then oryx_contextmenu(param4) ;* param4 is the click position end case event = "UPDATE_PAGE" gosub get_orders end case Case control = 'MENU' valid = oryxlib_standard_menu(focus)
See the bottom part of the code where I catch the UPDATE_PAGE event. Not sure what this is called or how it works, but isn't this a "commuter routine?" Basically , I don't know that much about OI.
When OI encounters a runtime error while performing a Post_Event call (and this error can occur in the event handler itself), it prevents an important global common variable in the Post_Event routine itself from being cleared. This variable is responsible for preventing multiple Post_Event handlers from being placed in the queue. As a result of this variable never being cleared, all future Post_Event calls will fail.
If you are interested to test this out, just put the following code in a routine and run it instead of restarting OI and see if the Post_Event begins to work:
COMMON /%QMANAGER%/ Queue@, bQueueActive@, RequstHold@ Queue@ = '' bQueueActive@ = '' RequestHold@ = ''