Welcome, Guest
Username: Password: Remember me
Visual Objects

Please use this forum to post questions about Visual Objects and Vulcan.NET
  • Page:
  • 1

TOPIC: OrderKeyCount failing?

OrderKeyCount failing? 1 year 4 months ago #1

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.


Please Log in or Create an account to join the conversation.

OrderKeyCount failing? 1 year 4 months ago #2


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)


or set the scope only inside the Methode with

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

and do the GoTop() by your self.


Gerhard Bunzel

Please Log in or Create an account to join the conversation.

OrderKeyCount failing? 1 year 4 months ago #3


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.
XSharp Development Team
The Netherlands
This email address is being protected from spambots. You need JavaScript enabled to view it.

Please Log in or Create an account to join the conversation.

OrderKeyCount failing? 1 year 4 months ago #4

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.


Please Log in or Create an account to join the conversation.

Last edit: by ic2.
  • Page:
  • 1