|
of_restore
|
|
Full name
|
pfc_n_cst_mru.of_restore
|
Access
|
public
|
Extend of
|
integer
|
Return value
|
integer
|
Prototype
|
public function integer of_restore(string,window)
|
Name
|
Datatype
|
li_index
|
Integer
|
li_itemcount
|
Integer
|
li_itemnumber
|
Integer
|
li_menuitemnumber
|
Integer
|
li_rc
|
Integer
|
li_registerindex
|
Integer
|
li_rowcount
|
Integer
|
lm_menu
|
menu
|
lnv_menu
|
n_cst_menu
|
lnv_mruattrib
|
n_cst_mruattrib
|
ls_menuitem
|
String
|
ls_menuitemtext
|
String
|
public function integer of_restore (string as_id, window aw_window);//////////////////////////////////////////////////////////////////////////////
//
// Function: of_Restore
//
// Access: public
//
// Arguments:
// as_id id to restore MRU information for
// aw_window Window to restore MRU information to
//
// Returns: integer
// SUCCESS = 1
// ERROR = -1
//
// Description:
// Restore MRU information to the menu on the window
//
//////////////////////////////////////////////////////////////////////////////
//
// 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_index, li_rc, li_rowcount, li_itemnumber
Integer li_menuitemnumber, li_registerindex, li_itemcount
String ls_menuitemtext, ls_menuitem
menu lm_menu
n_cst_menu lnv_menu
n_cst_mruattrib lnv_mruattrib
// check arguments
if isnull(aw_window) or not isvalid(aw_window) or &
isnull(as_id) or (as_id = "") then
return -1
end if
// Must have a menu on the window (response and child should not have menu)
If aw_window.MenuName = "" Then
return -1
end if
// Trim and Convert the ID to lower case.
as_id = Trim(Lower(as_id))
// ID must be registered to restore info
li_registerindex = of_GetRegistered( as_id )
if li_registerindex > 0 then
li_itemcount = inv_register[li_registerindex].ii_itemcount
else
return -1
end if
// filter out non id data
of_Filter("s_id='" + as_id + "'")
of_Sort("n_identity D")
// get the menu info for what we want to compare
ls_menuitem = is_menuitemstring + "1"
li_rc = lnv_menu.of_GetMenuReference(aw_window.menuid, ls_menuitem, lm_menu)
if li_rc < 1 then return -1
// check for changed items. if row 1 in datastore and first mru item don't match (rc <> 1)
// then restore the mru items
li_rc = of_FindItem(lm_menu.text, 0)
if li_rc = 1 then
// restore datastore (unfilter and sort)
of_Filter("")
of_Sort("n_identity D")
return li_rc
end if
// add items to menu -- setredraw function does not work on a menu
// loop until out of ds rows or all item spaces have been added to menu
li_rc = 0
li_index = 0
li_itemnumber = 0
li_rowcount = ids_mrukeys.rowcount()
Do Until (li_index >= li_rowcount) or (li_itemnumber >= li_itemcount)
li_index++
of_GetItem(li_index, lnv_mruattrib)
li_itemnumber++
ls_menuitemtext = "&" + String(li_itemnumber) + " " + lnv_mruattrib.is_menuitemname
li_rc = of_UpdateVisuals(aw_window, ls_menuitemtext, li_itemnumber)
if li_rc < 1 then exit
Loop
// add the menu divider bar if we have items on the menu
if (li_rc > 0) and (li_itemnumber > 0) then
of_AddMenubarLine(aw_window)
end if
// restore datastore (unfilter and sort)
of_Filter("")
of_Sort("n_identity D")
return li_rc
end function