|
of_buildsortattrib
|
|
Full name
|
pfc_n_cst_dwsrv_sort.of_buildsortattrib
|
Access
|
protected
|
Extend of
|
integer
|
Return value
|
integer
|
Prototype
|
protected function integer of_buildsortattrib(ref n_cst_sortattrib)
|
Name
|
Datatype
|
lb_exclude
|
boolean
|
li_exclude
|
integer
|
li_i
|
integer
|
li_j
|
integer
|
li_k
|
integer
|
li_numcols
|
integer
|
li_numcomputes
|
integer
|
lnv_string
|
n_cst_string
|
ls_computes
|
string[]
|
ls_dbname
|
string
|
ls_sortcolumns_all
|
string[]
|
ls_sortcolumns_exc
|
string[]
|
protected function integer of_buildsortattrib (ref n_cst_sortattrib anv_sortattrib);//////////////////////////////////////////////////////////////////////////////
//
// Function: of_BuildSortAttrib
//
// Access: Protected
//
// Arguments:
// anv_sortattrib: A NVO attribute class, passed by reference, that
// will hold sort information used by the Sort dialogs.
//
// Returns: Integer
// 1 if it succeeds and -1 if an error occurs.
//
// Description: Prepares the sort information required by the
// Specify Sort dialogs.
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 5.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_numcols
integer li_i
integer li_j
integer li_k
integer li_numcomputes
integer li_exclude
string ls_computes[]
string ls_dbname
string ls_sortcolumns_all[] // Hold all sort columns prior to any exclusions.
string ls_sortcolumns_exc[] // Hold sort columns after excluding appropriate ones.
boolean lb_exclude
n_cst_string lnv_string
// Validate dw reference.
If IsNull(idw_Requestor) Or Not IsValid(idw_Requestor) Then Return -1
// Get the current sort for the datawindow.
anv_sortattrib.is_sort = of_GetSort()
// Remove space after the comma(s) (convert ', ' to ',').
anv_sortattrib.is_sort = lnv_string.of_GlobalReplace (anv_sortattrib.is_sort, ', ', ',')
// Parse the original sort into separate elements.
of_ParseSortAttrib ( anv_sortattrib.is_sort, anv_sortattrib )
// Get all the column names on the datawindow.
li_numcols = of_GetObjects(ls_sortcolumns_all, "column", "*", ib_visibleonly)
// Get all the computed column names on the datawindow and add them to the array.
li_numcomputes = of_GetObjects( ls_computes, "compute", "*", ib_visibleonly)
FOR li_i = 1 to li_numcomputes
li_numcols++
ls_sortcolumns_all[li_numcols] = ls_computes[li_i]
NEXT
// See if any columns were set to be excluded from the sort display
// and create a new list of sort columns.
li_exclude = UpperBound(is_excludecolumns)
FOR li_j = 1 to li_numcols
lb_exclude = FALSE
FOR li_i = 1 to li_exclude
IF Lower(is_excludecolumns [li_i]) = Lower(ls_sortcolumns_all[li_j]) THEN
lb_exclude = TRUE
EXIT
END IF
NEXT
IF Not lb_exclude THEN
li_k++
ls_sortcolumns_exc[li_k] = ls_sortcolumns_all[li_j]
END IF
NEXT
// Copy the list of appropriate sort columns to the nvo.
anv_sortattrib.is_sortcolumns = ls_sortcolumns_exc
li_numcols = UpperBound(anv_sortattrib.is_sortcolumns)
// Get the column displayname.
CHOOSE CASE of_GetColumnnameSource ( )
CASE 0
// Use dw Column Names
FOR li_i = 1 to li_numcols
anv_sortattrib.is_colnamedisplay[li_i] = anv_sortattrib.is_sortcolumns[li_i]
NEXT
CASE 1
// Use Database Names
FOR li_i = 1 to li_numcols
ls_dbname = idw_Requestor.Describe ( anv_sortattrib.is_sortcolumns[li_i] + ".DbName" )
IF ls_dbname = "" OR ls_dbname = "!" THEN ls_dbname = anv_sortattrib.is_sortcolumns[li_i]
anv_sortattrib.is_colnamedisplay[li_i] = ls_dbname
NEXT
CASE 2
// Use Column Headers
FOR li_i = 1 to li_numcols
anv_sortattrib.is_colnamedisplay[li_i] = &
of_GetHeaderName ( anv_sortattrib.is_sortcolumns[li_i] )
NEXT
END CHOOSE
// Determine if LookUpDisplay should automatically be added when creating sort strings
// using the PFC SetSort Dialogs.
FOR li_i = 1 to li_numcols
IF of_GetUseDisplay() THEN
anv_sortattrib.ib_usedisplay[li_i] = of_UsesDisplayValue(anv_sortattrib.is_sortcolumns[li_i])
ELSE
anv_sortattrib.ib_usedisplay[li_i] = FALSE
END IF
NEXT
Return 1
end function