OrderKeyCount failing?

Public support forum for peer to peer support with related to the Visual Objects and Vulcan.NET products
Post Reply
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

OrderKeyCount failing?

Post by ic2 »

What could be wrong in these 4 lines of code?

uRet1:=SELF:oOwner:Server:OrderScope(TOPSCOPE, "X")
// Note: uRet1 and uRet2 are nil, but if I enter the very same line in debugger I get the correct value...
uRet2:=SELF:oOwner:Server:OrderScope(BOTTOMSCOPE, "X")
SELF:oOwner:Server:GoTop() SELF:oOwner:nNowInFilter:=SELF:oOwner:Server:OrderKeyCount() // ->does not return 1 sometimes

In postinit, I set SELF:oOwner:=uExtra and uExtra is the dbf used in the calling window (an invoice window). When I set the orderscope to "X" (in this message; in reality the actual = an existing invoice number) the orderscope works (we can see that the calling window only contains 1 invoice if e.g. a tabele view is opened) but at the same time OrderKeyCOunt sometimes returns all records of the database. Most of the times both the scope itself and the value to nNowInFilter work fine. I can not see what causes it not to work sometimes and why.

Dick
g.bunzel@domonet.de
Posts: 97
Joined: Tue Mar 01, 2016 11:50 am
Location: Germany

OrderKeyCount failing?

Post by g.bunzel@domonet.de »

Dick,

every Server:OrderScope(...) has a GoTop() inside and a lot of overhead. Have a look at the SDK.

This is my Method to set a Scope. Had never a problem with this.

METHOD SetScope (uTop, uBottom) CLASS dbMyServer
// Sets the scope in one step...

Default(@uBottom, uTop)

SELF:OrderTopScope := uTop
SELF:OrderScope(BOTTOMSCOPE, uBottom)

RETURN NIL

or set the scope only inside the Methode with

SELF:OrderTopScope := uTop
SELF:OrderBottomScope := uBottom

and do the GoTop() by your self.


HTH

Gerhard Bunzel
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

OrderKeyCount failing?

Post by robert »

Dick,

VO or Vulcan ?

Also, OrderScope() returns the current scope value, so a return value of NIL when there was no previous scope seems OK to me.
And when you execute the expression later in the debugger you will indeed get a value back, because you have just set it with OrderScope()!

Also the GoTop() is not needed. OrderScope() already does that

Finally w.r.t. OrderKeyCount():
There must be an explanation why this sometimes works and sometimes not. But without seeing the whole code I have no idea why.
Maybe some other code is changing the order and you are measuring the OrderKeyCount for this other order that does not have a scope.
I would also advise to include the name of the order that you want to check as parameter to OrderKeyCount() to prevent this.
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

OrderKeyCount failing?

Post by ic2 »

Hello Robert, Gerhard,

It's VO.
@Gerhard:sounds clever to me what you do. However, setting the orderscope itself isn't the problem. It's the OrderKeyCount that fails.

I can imagine it's hard to say anything but basically this the code which runs, nothing else. It sets the orderscope, apparently successful, and then does not show the correct orderkeycount - in rare cases. I'll certainly add the index as parameter which may make the difference.

About the GoTop: I added that because the help explicitly says:

Although not shown in the examples below, the GoTop() or some other pointer mechanism, should be used immediately following the OrderScope() method calls to invoke the scope itself.

Added 16:54: to be sure I now do the following: if the amount in OrderKeyCount is not 1 (which it should be in that specific method) I retry with Count(). This is slower but will probably show 1 for sure. At least the user then knows that the database is really filtered, as I show the amount in the filter on the screen.

Dick
Post Reply