|
of_buildfilterstring
|
|
Full name
|
pfc_w_filtersimple.of_buildfilterstring
|
Access
|
public
|
Override of
|
string
|
Return value
|
string
|
Prototype
|
public function string of_buildfilterstring()
|
Name
|
Datatype
|
li_foundrow
|
integer
|
li_i
|
integer
|
li_rcount
|
integer
|
lnv_string
|
n_cst_string
|
ls_and_or
|
string
|
ls_colname
|
string
|
ls_coltype
|
string
|
ls_exp_left
|
string
|
ls_expression
|
string
|
ls_filter
|
string
|
ls_oper
|
string
|
ls_value
|
string
|
public function string of_buildfilterstring ();//////////////////////////////////////////////////////////////////////////////
//
// Function: of_BuildfilterString
//
// Access: Public
//
// Arguments: None
//
// Returns: String
// The new filter string.
// '!' if an error is encountered.
//
// Description: This function will build a valid datawindow filter string
// from the values entered in the filter selection datawindow.
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 5.0 Initial version
// 5.0.03 Corrected to check/build for all column types.
// 7.0 Added "char" datatype to case statement
//
//////////////////////////////////////////////////////////////////////////////
//
// 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.
//
//////////////////////////////////////////////////////////////////////////////
string ls_exp_left, ls_oper, ls_value, ls_colname, ls_filter, ls_and_or
string ls_coltype, ls_expression
integer li_i, li_rcount, li_foundrow
n_cst_string lnv_string
// Accept the latest changes.
If dw_filter.AcceptText() <> 1 Then Return '!'
// Get the values from the filter datawindow.
li_rcount = dw_filter.RowCount ( )
FOR li_i = 1 to li_rcount
// Construct the left side of the expression.
ls_exp_left = dw_filter.GetItemString ( li_i, "colname" )
IF IsNull(ls_exp_left) THEN ls_exp_left = ""
IF ls_exp_left <> "" AND li_i > 1 THEN
ls_filter = ls_filter + " " + ls_and_or
END IF
// Construct the operator.
ls_oper = dw_filter.GetItemString ( li_i, "oper" )
IF IsNull(ls_oper) THEN ls_oper = ""
// Get the value.
ls_value = dw_filter.GetItemString ( li_i, "colvalue" )
IF IsNull (ls_value) THEN ls_value = ""
// Construct the "AND" or "OR" for the expression.
ls_and_or = dw_filter.GetItemString (li_i, "and_or" )
IF IsNull(ls_and_or) THEN ls_and_or = ""
// Get the column name.
li_foundrow = idwc_cols.Find ('display_column = "' + ls_exp_left + '"', &
1, idwc_cols.RowCount ())
IF li_foundrow > 0 THEN
ls_colname = idwc_cols.GetItemString(li_foundrow, "columnname")
ELSE
ls_colname = ls_exp_left
END IF
// Get the column type.
ls_coltype = Left(inv_filterattrib.idw_dw.Describe ( ls_colname + ".ColType" ), 5)
// Determine the correct expression.
Choose Case ls_coltype
// CHARACTER DATATYPE
Case "char(", "char"
If Pos(ls_value, '~~~"') =0 And Pos(ls_value, "~~~'") =0 Then
// No special characters found.
If Pos(ls_value, "'") >0 Then
// Replace single quotes with special chars single quotes.
ls_value = lnv_string.of_GlobalReplace(ls_value, "'", "~~~'")
End If
End If
ls_expression = "'" + ls_value + "'"
// DATE DATATYPE
Case "date"
ls_expression = "Date('" + ls_value + "')"
// DATETIME DATATYPE
Case "datet"
ls_expression = "DateTime('" + ls_value + "')"
// TIME DATATYPE
Case "time", "times"
ls_expression = "Time('" + ls_value + "')"
// NUMBER
Case Else
ls_expression = ls_value
End Choose
// Build the filter string.
ls_filter += " " + ls_colname + " " + ls_oper + " " + ls_expression
NEXT
Return Trim(ls_filter)
end function
Name
|
Owner
|
datawindow.accepttext |
datawindow
|
datawindow.describe |
datawindow
|
datawindow.getitemstring |
datawindow
|
datawindow.rowcount |
datawindow
|
datawindowchild.find |
datawindowchild
|
datawindowchild.getitemstring |
datawindowchild
|
datawindowchild.rowcount |
datawindowchild
|
systemfunctions.isnull |
systemfunctions
|
systemfunctions.left |
systemfunctions
|
systemfunctions.pos |
systemfunctions
|
systemfunctions.trim |
systemfunctions
|
pfc_n_cst_string.of_globalreplace |
pfc_n_cst_string
|