RE: When is CompareRows done? (Real Studio network user group Mailinglist archive)

Back to the thread list
Previous thread: Getting record count of a record set
Next thread: Reading comma delimited data


RB and the StuffIt Engine   -   syounker bco.com
  RE: When is CompareRows done?   -   Hadley, Joshua
   RE: When is CompareRows done?   -   Hadley, Joshua
    RE: When is CompareRows done?   -   Hadley, Joshua
     When is CompareRows done?   -   Hadley, Joshua
      RecordSets in RB4.5   -   Chuck Weger
     Re: When is CompareRows done?   -   Charles Yeomans
     Re: When is CompareRows done?   -   Brady Duga
     Growing multiple items   -   Randall Meadows
    RE: When is CompareRows done?   -   Joseph J. Strout
    Re: When is CompareRows done?   -   Brady Duga
    RE: When is CompareRows done?   -   Joseph J. Strout
    Re: Reading comma delimited data   -   chris

RE: When is CompareRows done?
Date: 30.08.02 00:37 (Thu, 29 Aug 2002 18:37:10 -0500)
From: Hadley, Joshua
>>But, thinking this out some more, I guess what I'll need to do is:
>> - make a New Event in my listbox subclass ("myCompareRows")
>> - call that new event from the CompareRows event
>> - put a timer on the window with the app.mousecursor rowcursor in
>>it
>> - set the mode of that timer in the new myCompareRows event
>
>Hmm, you could, but here's a more encapsulated alternative. Make a
>subclass of Timer that resets the mouse cursor. Make a property of
>that type in your Listbox subclass. Now, in your CompareRows event
>(in the listbox subclass), create a timer only if you don't already
>have one -- if you do, then just reset it. Presto!

OK, that's much easier; I think about 4 lines of code added to what I
already have will end up with what you describe (checking for nil,
basically).

Good stuff, much cleaner solution, too! Thanks again!

---
Subscribe to the digest:
<mailto:<email address removed>>
Unsubscribe:
<mailto:<email address removed>>

RE: When is CompareRows done?
Date: 30.08.02 00:05 (Thu, 29 Aug 2002 18:05:10 -0500)
From: Hadley, Joshua
>> My only additional concern is, the way I have implemented
>> it (an instance of a *subclass* of Timer is instantiated
>> in CompareRows; CompareRows gets called like hundreds of
>> times during the process of a Sort)

> Ow! So your making hundreds of timers. It'd be much more
> efficient to just have *one* timer, say right there on the
> Window, and simply reset it in CompareRows (by setting
> modeand then mode.
>
> As you've done it, the timers will indeed go away when
> their time is up, but it's very wasteful (and I'd expect
> it to cause some flickering of the cursor as they fight
> for control of it, too).

Hi Joe,

Thanks for the tip. I should mention that what I have is a subclass of
ListBox, in which I have my own sort routine in CompareRows. I set the
cursor to watchcursor in the SortColumn event. There's no flickering,
because (I guess) the instance of each of the timers is going away before
the .action gets fired (??). But no doubt it is wasteful; that's why I
mentioned it ;-)

But, thinking this out some more, I guess what I'll need to do is:
- make a New Event in my listbox subclass ("myCompareRows")
- call that new event from the CompareRows event
- put a timer on the window with the app.mousecursor rowcursor in
it
- set the mode of that timer in the new myCompareRows event

Does that seem like a more sensible approach? Should be easy to do.

Again, thanks for the great tips on this, I really appreciate it!

---
Subscribe to the digest:
<mailto:<email address removed>>
Unsubscribe:
<mailto:<email address removed>>

RE: When is CompareRows done?
Date: 29.08.02 22:57 (Thu, 29 Aug 2002 16:57:27 -0500)
From: Hadley, Joshua
Brady Duga wrote:
> Hmm - perhaps you could use a watchdog timer. So, in comparerows set
> the cursor to a stopwatch, then set the interval of some magic timer
> to, say, half a second. In the action event of the timer, set the
> cursor back to an arrow cursor. Every time you hit CompareRows, you
> reset this timer, so it won't fire until no sorting has been done for
> half a second, probably long enough to say it is done, but not long
> enough to annoy a user. Seems like it would work, but I have never
> used CompareRows, so perhaps there is some other issue I am missing...

Brady,

Hey, hanks a lot for this tip! It does the trick for me, for now. I have my
timer.period0 and it is giving the expected result, no problem. Even
works in reverse ;-)

My only additional concern is, the way I have implemented it (an instance of
a *subclass* of Timer is instantiated in CompareRows; CompareRows gets
called like hundreds of times during the process of a Sort), I'm not sure
whether each instance is going to get GC'ed properly; I guess I will need to
be on the lookout for memory leaks and/or hope that GC is doing its job
properly! Did a quick check with 'About This Computer'/Balloons, looking at
the memory usage; so far so good.

But anyway, the functionality I was seeking is definitely there; thanks
again for a creative solution to this!

Josh

---
Subscribe to the digest:
<mailto:<email address removed>>
Unsubscribe:
<mailto:<email address removed>>

When is CompareRows done?
Date: 29.08.02 21:26 (Thu, 29 Aug 2002 15:26:22 -0500)
From: Hadley, Joshua
Is there any event or condition I can test for to know when the CompareRows
is fully done with a sort of a ListBox? Reason is, I want to set
app.mousecursor=watchcursor at the beginning of the sort, and then set it
back to arrowcursor when the sort is done; as this does not happen
automatically (RB 4.0.2) and I don't want my users to wonder whether the
machine is hung up or something.

I have tried looking over the row1 and row2 values as they come into the
CompareRows event; there's apparently some sort of binary/bubble/quicksort
going on there, but I am having trouble identifying a consistent pattern of
these numbers that indicates the end of that. Maybe that's not even the
right place to look; I thought it was promising at first but the pattern of
values varies depending on list content.

Any advice appreciated . . .

Josh

---
Subscribe to the digest:
<mailto:<email address removed>>
Unsubscribe:
<mailto:<email address removed>>

Re: When is CompareRows done?
Date: 29.08.02 21:39 (Thu, 29 Aug 2002 16:39:14 -0400)
From: Charles Yeomans

On Thursday, August 29, 2002, at 04:26 PM, Hadley, Joshua wrote:

> Is there any event or condition I can test for to know when the
> CompareRows
> is fully done with a sort of a ListBox? Reason is, I want to set
> app.mousecursor=watchcursor at the beginning of the sort, and then set
> it
> back to arrowcursor when the sort is done; as this does not happen
> automatically (RB 4.0.2) and I don't want my users to wonder whether the
> machine is hung up or something.
>
> I have tried looking over the row1 and row2 values as they come into the
> CompareRows event; there's apparently some sort of
> binary/bubble/quicksort
> going on there, but I am having trouble identifying a consistent
> pattern of
> these numbers that indicates the end of that. Maybe that's not even the
> right place to look; I thought it was promising at first but the
> pattern of
> values varies depending on list content.
>

It looks like there is no event that fires after the sort is complete.
What you could do is prevent RB from sorting and instead call your own
sort in the SortColumn or HeaderPressed events. Then you'd know when
the sort is finished.

Charles Yeomans


---
Subscribe to the digest:
<mailto:<email address removed>>
Unsubscribe:
<mailto:<email address removed>>

Re: When is CompareRows done?
Date: 29.08.02 21:53 (Thu, 29 Aug 2002 13:53:14 -0700)
From: Brady Duga

On Thursday, August 29, 2002, at 01:26 PM, Hadley, Joshua wrote:

> Is there any event or condition I can test for to know when the
> CompareRows
> is fully done with a sort of a ListBox? Reason is, I want to set
> app.mousecursor=watchcursor at the beginning of the sort, and then set
> it
> back to arrowcursor when the sort is done;

Hmm - perhaps you could use a watchdog timer. So, in comparerows set
the cursor to a stopwatch, then set the interval of some magic timer
to, say, half a second. In the action event of the timer, set the
cursor back to an arrow cursor. Every time you hit CompareRows, you
reset this timer, so it won't fire until no sorting has been done for
half a second, probably long enough to say it is done, but not long
enough to annoy a user. Seems like it would work, but I have never used
CompareRows, so perhaps there is some other issue I am missing...

--Brady
The La Jolla Underground

---
Subscribe to the digest:
<mailto:<email address removed>>
Unsubscribe:
<mailto:<email address removed>>

RE: When is CompareRows done?
Date: 29.08.02 23:02 (Thu, 29 Aug 2002 15:02:35 -0700)
From: Joseph J. Strout
At 4:57 PM -0500 8/29/02, Hadley, Joshua wrote:

>My only additional concern is, the way I have implemented it (an instance of
>a *subclass* of Timer is instantiated in CompareRows; CompareRows gets
>called like hundreds of times during the process of a Sort)

Ow! So your making hundreds of timers. It'd be much more efficient
to just have *one* timer, say right there on the Window, and simply
reset it in CompareRows (by setting modeand then mode.

As you've done it, the timers will indeed go away when their time is
up, but it's very wasteful (and I'd expect it to cause some
flickering of the cursor as they fight for control of it, too).

Cheers,
- Joe

Re: When is CompareRows done?
Date: 29.08.02 23:02 (Thu, 29 Aug 2002 15:02:37 -0700)
From: Brady Duga

On Thursday, August 29, 2002, at 02:57 PM, Hadley, Joshua wrote:

>
> Hey, hanks a lot for this tip! It does the trick for me, for now. I
> have my
> timer.period0 and it is giving the expected result, no problem. Even
> works in reverse ;-)

Cool, I'm glad it worked. Timers are a great feature of RB, they solve
all sorts of interesting dilemmas.
>
> My only additional concern is, the way I have implemented it (an
> instance of
> a *subclass* of Timer is instantiated in CompareRows; CompareRows gets
> called like hundreds of times during the process of a Sort),

You might consider having a single global timer. It could be in your
window or on the app object. In any case, I THINK if you reset the
period of an already running timer, it resets the timer. So, instead of
making a new timer in every call, you would just reset the period of
some instance of a timer, that could just be in your window. Then there
is no instantiation and no deletion.

--Brady
The La Jolla Underground

---
Subscribe to the digest:
<mailto:<email address removed>>
Unsubscribe:
<mailto:<email address removed>>

RE: When is CompareRows done?
Date: 30.08.02 00:04 (Thu, 29 Aug 2002 16:04:07 -0700)
From: Joseph J. Strout
At 6:05 PM -0500 8/29/02, Hadley, Joshua wrote:

>Thanks for the tip. I should mention that what I have is a subclass of
>ListBox

Ah, that does complicate it a little. But not much.

>But, thinking this out some more, I guess what I'll need to do is:
> - make a New Event in my listbox subclass ("myCompareRows")
> - call that new event from the CompareRows event
> - put a timer on the window with the app.mousecursor rowcursor in
>it
> - set the mode of that timer in the new myCompareRows event

Hmm, you could, but here's a more encapsulated alternative. Make a
subclass of Timer that resets the mouse cursor. Make a property of
that type in your Listbox subclass. Now, in your CompareRows event
(in the listbox subclass), create a timer only if you don't already
have one -- if you do, then just reset it. Presto!

Cheers,
- Joe

-