Foxhound is the better* Database Monitor for SQL Anywhere.
*better: More thorough, more relevant, more effective.
...more Alerts, more All Clears, more details, more control in your hands.
|
Breck Carter
Last modified: November 17, 1998
mail to: bcarter@bcarter.com
The code for Encapsulated DataWindow Searching has been extended to handle numeric, date, time and DateTime columns as well as strings. Default conversion formats are provided for the new data types, and the object function of_set_string_format() has been provided to let you change the formats. For example, you can let your users type "mm/dd/yy", "yyyy mm dd" or "mmm dd, yyyy" for a date.
To download:
PowerBuilder 4 version: findcode.zip
PowerBuilder 5 version: findcod5.zip
- includes support for DataWindow data type "long"
PowerBuilder 6.5 version: findcod6.zip
A demonstration program is included; here's what it looks like:
Setup is described in the documentation() function contained in the u_sle_find object in uslefind.pbl:
/* Documentation() Function in U_SLE_Find -------------------------------------- Copyright (C) 1996, 1998 Breck Carter For more information see www.bcarter.com or bcarter@bcarter.com. u_sle_find - SingleLineEdit for DataWindow find and scroll. Description: Scroll-while-you-type facility for searching a DataWindow. Modification History: 1998 11 11 BC Data type "long" supported as "numeric". Basic Setup: For example, a DataWindow control called dw_table is associated with a DataWindow object that contains a column called "entry". A SingleLineEdit control called sle_entry is created using this user object. It is enabled by the following statements in the window.open event: integer li_RC li_RC = sle_entry.of_register ( dw_table, "entry" ) if li_RC <> 1 then halt close end if That's all there is to it; other function calls are optional. Beeping On Not Found: The following call enables beeping when the search string is not found; this is the default behaviour: sle_entry.of_set_beep() The following call disables all beeping: sle_entry.of_disable_beep() If beeping is enabled, the following call enables repeated beeping when repeated attempts are made to extend a failing match string: sle_entry.of_set_repeat_beep() If beeping is enabled, the following call disables repeated beeping so that only one beep is heard when a search string is not found even if the user continues to type characters; this is the default behaviour: sle_entry.of_disable_repeat_beep() Case-Sensitive and Case-Insensitive Matching: The following call enables case-sensitive (match on case) searching: sle_entry.of_set_case_sensitive() The following call enables case-insensitive searching; this is the default behaviour: sle_entry.of_set_case_insensitive() Find Next and Find Previous Accelerator Keys: By default the plus and minus keys on the numeric keypad are the accelerator keys for find next and find previous matching rows. The following calls show the default values; you can change the accelerator keys by substituting different key code values: sle_find.of_set_find_next_key ( KeyAdd! ) sle_find.of_set_find_previous_key ( KeySubtract! ) The following calls disable find next and find previous: sle_find.of_disable_find_next_key() sle_find.of_disable_find_previous_key() Clear Find Accelerator Key: By default the escape key is the accelerator key for clearing the SingleLineEdit contents. The following calls show the default values; you can change the accelerator keys by substituting different key code values: sle_find.of_set_clear_find_key ( KeyEscape! ) The following call disables the clear find accelerator key: sle_find.of_disable_clear_find_key() Pass-Through Keys: For ease-of-use certain keystrokes are passed on to the DataWindow control even though this SingleLineEdit control still has focus. This makes it unnecessary for the user to tab back and forth to switch between searching (e.g., find next) and scrolling (e.g., next page) operations. Pass-Through Enter Key: One common enhancement is to pass Enter key presses to the DataWindow; this is enabled by the following statment: sle_entry.of_set_enter_processing & ( KeyEnter!, "pbm_dwnprocessenter" ) To disable pass-through processing of the Enter key (which is the default behaviour), code the following: sle_entry.of_disable_enter_processing() Scrolling Accelerator Keys: Several other keystrokes are passed through to the DataWindow to perform scrolling by page and row. The following calls show the default values; you can change the accelerator keys by substituting different key code values: sle_find.of_set_scroll_next_page_key ( KeyPageDown! ) sle_find.of_set_scroll_next_row_key ( KeyDownArrow! ) sle_find.of_set_scroll_prior_page_key ( KeyPageUp! ) sle_find.of_set_scroll_prior_row_key ( KeyUpArrow! ) The following calls disable the scrolling accelerator keys: sle_find.of_disable_scroll_next_page_key() sle_find.of_disable_scroll_next_row_key() sle_find.of_disable_scroll_prior_page_key() sle_find.of_disable_scroll_prior_row_key() Note on Column Data Types: The following formats are used when converting DataWindow column data types to string format for comparison purposes: Default of_set_string_format() Data Type String Format Call Allowed --------- ------------- ------------ char(nn) none no compute none no number none yes decimal(n) none yes date yyyy mm dd yes datetime yyyy mm dd hh:mm:ss.ffffff yes time hh:mm:ss.ffffff yes timestamp not supported n/a If the default string format does not agree with the column's display format, of_set_string_format may be called to make them agree. Here are some examples: // Allow keyboard entry of decimal point: li_RC = sle_purchase_amount.of_set_string_format ( "0.00" ) if li_RC <> 1 then return end if // Change the date entry format: li_RC = sle_purchase_date.of_set_string_format ( "mmm dd, yyyy" ) if li_RC <> 1 then return end if // Change the time entry format: li_RC = sle_purchase_date.of_set_string_format ( "hh mm" ) if li_RC <> 1 then return end if */
Breck Carter can be reached by phone at (416) 763-5200 or via email at bcarter@bcarter.com.