|
of_register
|
|
Full name
|
pfc_n_cst_tmgmultiple.of_register
|
Access
|
public
|
Extend of
|
integer
|
Return value
|
integer
|
Prototype
|
public function integer of_register(powerobject,string,long,integer)
|
Name
|
Datatype
|
idtm_nexttime
|
datetime
|
it_now
|
time
|
li_cnt
|
integer
|
li_firstopening
|
integer
|
li_idx
|
integer
|
li_rc
|
integer
|
ll_row
|
long
|
lnv_tmgentry
|
n_cst_tmgregisterattrib
|
ls_filter
|
string
|
public function integer of_register (powerobject apo_object, string as_eventname, long al_interval, integer ai_notifystyle);//////////////////////////////////////////////////////////////////////////////
//
// Function: of_Register
//
// Access: public
//
// Arguments:
// apo_object : powerobject ; Object to be notified
// as_eventname : string; Event to be notified
// al_interval : long ; How often to notify (in seconds)
// ai_notifystyle: integer ; The style - either TRIGGEREVENT or POSTEVENT.
//
// Returns: integer
// SUCCESS = 1
// ERR = -1
//
// Description:
// Registers the passed object/event pair.
//
// Note:
// If the object/event pair has already been registered then replace the
// old interval with the new interval.
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 6.0 Initial version
//
//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1996-1997 Sybase, Inc. and its subsidiaries. All rights reserved.
// Any distribution of the PowerBuilder Foundation Classes (PFC)
// source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//
//////////////////////////////////////////////////////////////////////////////
integer li_cnt
integer li_idx
integer li_firstopening
integer li_rc
long ll_row
string ls_filter
time it_now
datetime idtm_nexttime
n_cst_tmgregisterattrib lnv_tmgentry
// Validate the arguments
If isnull(apo_object) Then Return -1
If Not isvalid(apo_object) Then Return -1
If len(trim(as_eventname)) = 0 Then Return -1
If ai_notifystyle <> TRIGGEREVENT And ai_notifystyle <> POSTEVENT Then Return -1
// Validate required references.
If IsNull(itmg_requestor) Or Not IsValid(itmg_requestor) Then Return -1
// No interrupts while processing
itmg_requestor.stop()
if al_interval < 1 then al_interval = 1
// Loop, see if the object/event pair has already been registered.
li_cnt = upperbound(inv_tmgregister)
For li_idx = 1 To li_cnt
If isvalid(inv_tmgregister[li_idx].ipo_notify) Then
If inv_tmgregister[li_idx].ipo_notify = apo_object And &
inv_tmgregister[li_idx].is_notifyevent = as_eventname Then
// Object already registered.
// Reset the interval and notifystyle.
// Main register list.
inv_tmgregister[li_idx].il_notifyinterval = al_interval
inv_tmgregister[li_idx].ii_notifystyle = ai_notifystyle
// Support register list.
idtm_nexttime = inv_datetime.of_RelativeDatetime( &
datetime(today(),now()), inv_tmgregister[li_idx].il_notifyinterval)
ls_filter = "index = "+string(li_idx)
li_rc = ids_list.SetFilter(ls_filter)
li_rc = ids_list.Filter()
ids_list.object.next_time[1] = idtm_nexttime
li_rc = ids_list.SetFilter('')
li_rc = ids_list.Filter()
// Calculate and set the new interval.
of_ReCalcInterval()
Return 1
End If
Else
If li_firstopening = 0 Then
// Save the first opening in the array, if there is one
li_firstopening = li_idx
End If
End If
Next
// No duplicate entries, needs to be added to the list
If li_firstopening > 0 Then
// Reuse the opening in the list.
li_idx = li_firstopening
Else
// Add it to the end of the list.
li_idx = li_cnt + 1
End If
// Add it to the Master list.
lnv_tmgentry.ipo_notify = apo_object
lnv_tmgentry.is_notifyevent = as_eventname
lnv_tmgentry.il_notifyinterval = al_interval
lnv_tmgentry.ii_notifystyle = ai_notifystyle
inv_tmgregister[li_idx] = lnv_tmgentry
// Add it to the Support list.
ll_row = ids_list.InsertRow(0)
ids_list.Object.index[ll_row] = li_idx
// create a new next time (current time plus the interval)
it_now = RelativeTime(now(), al_interval)
idtm_nexttime = datetime(today(),it_now)
ids_list.Object.next_time[ll_row] = idtm_nexttime
// Calculate and set the new interval.
of_ReCalcInterval()
Return 1
end function
Name
|
Owner
|
datastore.filter |
datastore
|
datastore.insertrow |
datastore
|
datastore.setfilter |
datastore
|
timing.stop |
timing
|
systemfunctions.datetime |
systemfunctions
|
systemfunctions.isnull |
systemfunctions
|
systemfunctions.isvalid |
systemfunctions
|
systemfunctions.len |
systemfunctions
|
systemfunctions.now |
systemfunctions
|
systemfunctions.relativetime |
systemfunctions
|
systemfunctions.string |
systemfunctions
|
systemfunctions.today |
systemfunctions
|
systemfunctions.trim |
systemfunctions
|
systemfunctions.upperbound |
systemfunctions
|
pfc_n_cst_tmgmultiple.of_recalcinterval |
pfc_n_cst_tmgmultiple
|
pfc_n_cst_datetime.of_relativedatetime |
pfc_n_cst_datetime
|