1. Glenn Barber
  2. PowerBuilder
  3. Friday, 24 March 2023 20:45 PM UTC

I have Selection Window (PB 2017 R3) with a text field where the user can type the name of a product.

One the keyup we capture the text and use it in a query that displays matching selections.

Whats the best way to ensure that the user has stopped typing for a period of time (~1/4 second?) before capturing the text and performing a query.

Accepted Answer
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 24 March 2023 21:05 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi Glenn

  FWIW: I've done this before using a "Timing" PB object. If the user keys another character before the timer goes off, then reset the timer. If not, the timer will eventually fire (at whatever interval you set) and then you can a) stop the timer and then b) process the characters that are present. If the user starts typing again, then re-start the timer.  HTH

Regards ... Chris

Comment
  1. mike S
  2. Saturday, 25 March 2023 12:51 PM UTC
timer.stop if using the timing object
  1. Helpful 2
  1. Glenn Barber
  2. Saturday, 25 March 2023 20:03 PM UTC
What are the advantages of using a timing object?
  1. Helpful
  1. Chris Pollach @Appeon
  2. Saturday, 25 March 2023 23:09 PM UTC
1) can have one or more running per object class

2) encapsulates timing & business functionality

3) can be inherited from PB's System Class

4) can be encapsulated inside a custom user object.
  1. Helpful
There are no comments made yet.
Glenn Barber Accepted Answer Pending Moderation
  1. Friday, 24 March 2023 21:39 PM UTC
  2. PowerBuilder
  3. # 1

I seem to be having some success capturing the sle.text  in the keyup

Then firing the timer Event for .25 seconds

In the timer event call a windows event which turns the timer off and calls the dw retrive  event with the captured text 

Of course this also means I may want to also delay until the prior retrive is complete.

This invites a borader question about best techniques for ensuring multiple processes are complete

 

 

Comment
  1. John Fauss
  2. Saturday, 25 March 2023 05:46 AM UTC
Unless you are using multi-threading via PB shared objects, your app has only a single thread executing that handles EVERYTHING... computations, mouse and keyboard interaction (events), responding to a timer "pop" (event), waiting for a data retrieval to complete (event), etc. The entire GUI of a PB application is managed by a single execution thread. While it may appear as if there are multiple "processes" running concurrently in an app, there is only one event message queue.

Asynchronous database operations (DBParm: Async=1) can free up the GUI while a retrieval is being processed by the database, but this only asks the database interface client/driver to NOT wait for a response to a retrieval request like normal - It does NOT perform the retrieval in a separate thread as one might expect. Async operation is available for use with many/most databases, except for SQL Server. The SQL Server client interfaces are certainly capable of supporting Async operations (look no further than how SQL Server Management Studio works), so I don't know why PB does not also support this feature... but that's another discussion, for another day.
  1. Helpful 1
There are no comments made yet.
mike S Accepted Answer Pending Moderation
  1. Friday, 24 March 2023 21:18 PM UTC
  2. PowerBuilder
  3. # 2

you could also just limit the number of items retrieved (100?) to those that match.  so for the first letter of the item you get 100, for the 2nd letter filter the 100 to see how many match.  if it is 0, do another retrieve of the top 100. 

You probably want to limit the number of items retrieved regardless of the use of the timer

Comment
  1. Chris Pollach @Appeon
  2. Friday, 24 March 2023 22:28 PM UTC
Hi Glenn;

I would suggest using the "TOP nnn" extension in your Select command to limit the result set significantly. HTH

Regards ... Chris
  1. Helpful
  1. Glenn Barber
  2. Friday, 24 March 2023 22:53 PM UTC
if the user enters a word they are looking for - then it doesnt appear anywhere in the list because we cut off after the top requests - they call us up and ask us why... we can always get the entire set and then allow them to find or filter in the set - but if the data was not anywhere it becomes a fishing expedition.



As it happens - so far using the timer is working out...
  1. Helpful 1
  1. Glenn Barber
  2. Friday, 24 March 2023 22:59 PM UTC
I need to rephrase - if the item with the word doesnt appear (in this case a specific title of an TV episode) - they call us to find out why its not there..

There are some cases where we do a pre-display count() function and let them know we are only going to retrive the first X number of rows and they need to fine tune their selection.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.