Hi John,
(option 1 due to René's excellent feedback)
It is possible to verify a DataWindow filter in different ways as described below.
I checked my samples using PB 2017 R2 Build 1769. My filter = "alfa = beta" to simulate typos in column names.
You can suppress user prompts using the NoUserPrompt DataWindow property. You may want to turn it back on after verifying your filter expression.
Alternatively, you can access the DataWindow buffer through a DataStore (using ShareData). DataStore behaves like prompting is turned off and cannot be turned on.
Option 1: Use DataWindow.NoUserPrompt
You can toggle implicit error messages using DW property = NoUserPrompt. Full code:
// Function: ApplyFilter(datawindow adw_data, string as_filter)
// Purpose: Apply filter indicating whether filter is valid.
int filterStatus
string currentPrompt
currentPrompt = adw_data.object.datawindow.NoUserPrompt
adw_data.object.datawindow.NoUserPrompt = 'yes'
filterStatus = adw_data.SetFilter(as_filter)
adw_data.object.datawindow.NoUserPrompt = currentPrompt
if filterStatus = 1 then
adw_data.Filter( )
return true
else
return false
end if
Option 2: Use DataStore as Intermediate
DataStore does not support "NoUserPrompt" (I receive null object reference). Full code:
// Function: ApplyFilter(datawindow adw_data, string as_filter): boolean
// Purpose: Apply filter indicating whether filter is valid.
datastore lds_data
blob dwContent
int filterStatus
lds_data = create datastore
dw_data.ShareData(lds_data)
filterStatus = lds_data.SetFilter(as_filter)
if filterStatus = 1 then
lds_data.Filter( )
return true
else
return false
end if
HTH
/Michael