FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to clear ordScope()
Posts: 169
Joined: Mon Feb 25, 2008 02:42 AM
How to clear ordScope()
Posted: Thu Oct 29, 2009 06:03 AM
Hi.. Greeting From Indonesia

Code (fw): Select all Collapse
function main()

use detail 
index on code to detail

SetMyFilter("001")

detail->(dbGotop())
do while !detail->(eof())
     ?detail->code
     detail->(dbSkip())
enddo
... work fine

ClearMyFilter()

detail->(dbGotop())
do while !detail->(eof())
     ?detail->code
     detail->(dbSkip())
enddo
... not work... still locked by scope, the scope is not clear

return nil

function SetMyFilter(cScope)
detail->(ordScope(0,cScope))
detail->(ordScope(1,cScope))
return nil

function ClearMyFilter()
detail->(ordScope(0,NIL))
detail->(ordScope(1,NIL))
return nil




.. How to clear my Scope

Regards
Fafi
Posts: 41
Joined: Thu Dec 22, 2005 07:39 AM
Re: How to clear ordScope()
Posted: Thu Oct 29, 2009 08:39 AM
Hello, Fafi !
It has to work!
But you miss ")" in the end of
Code (fw): Select all Collapse
detail->(ordScope(0,NIL))
Best regards!

Sergey (Loach) Abelev

fwh 9.04/xHarbour 1.2.1 (Rev. 6406)/Bcc55
Posts: 169
Joined: Mon Feb 25, 2008 02:42 AM
Re: How to clear ordScope()
Posted: Thu Oct 29, 2009 10:03 AM

Thank's Mr. Loach !

I forgot my ) at the end..

But still not work..

Is OrdScope(0,NIL) correct ? for clear the scope

Regards
fafi

Posts: 41
Joined: Thu Dec 22, 2005 07:39 AM
Re: How to clear ordScope()
Posted: Thu Oct 29, 2009 11:08 AM
This method absolutely correct!
I use OrdScope(0,nil) in all projects and scops are clears...
Try to look on ordkeycount() after the OrdScope(0,NIL). Then you can try to do :
Code (fw): Select all Collapse
function ClearMyFilter()
local oldarea:=select()
select datail
ordScope( 0, nil )
ordScope( 1, nil )
SET SCOPE TO 
select(oldarea)
return nil
Best regards!

Sergey (Loach) Abelev

fwh 9.04/xHarbour 1.2.1 (Rev. 6406)/Bcc55
Posts: 169
Joined: Mon Feb 25, 2008 02:42 AM
Re: How to clear ordScope()
Posted: Thu Oct 29, 2009 11:16 AM

Thank's Mr. Loach

I added SET SCOPE TO

It's work now...

Thank's so much

Regards
Fafi

Posts: 41
Joined: Thu Dec 22, 2005 07:39 AM
Re: How to clear ordScope()
Posted: Thu Oct 29, 2009 11:54 AM
Ok, mr. Fafi, but it still not normal :-)
SET SCOPE TO it's just analog of ordScope( 0, nil ) and ordScope( 1, nil )...
I think that problem was in work area. In you case
Code (fw): Select all Collapse
select datail
ordScope( 0, nil )
ordScope( 1, nil )
select(oldarea)

will also work correct IMHO. I don't use SET SCOPE TO. In my projects I use 1->(ordScope( 0, nil )) and never used datail->(ordScope( 0, nil )). But the last one must work correct also. Possible, your program has not time to clear the scopes...
Best regards!

Sergey (Loach) Abelev

fwh 9.04/xHarbour 1.2.1 (Rev. 6406)/Bcc55
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Re: How to clear ordScope()
Posted: Thu Oct 29, 2009 12:24 PM

I have gone through similar problems in the past

I always close the database and reopen it in order to clear the scopes and it is working just fine

HTH

Richard

http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: How to clear ordScope()
Posted: Thu Oct 29, 2009 02:28 PM
Richard Chidiak wrote:I have gone through similar problems in the past

I always close the database and reopen it in order to clear the scopes and it is working just fine

HTH

Richard


It is not needed at all. The problem must lies elsewhere.

EMG
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: How to clear ordScope()
Posted: Thu Oct 29, 2009 04:28 PM
From the ord.ch file:

Code (fw): Select all Collapse
#command SET SCOPE TO                 => OrdScope( TOPSCOPE, nil );
                                        ; OrdScope( BOTTOMSCOPE, nil )


So SET SCOPE TO is just setting both top and bottoms scopes to nil. So something else is the problem, or maybe you are interpreting your test results incorrectly (maybe the file's natural order is the same as the indexed order?).

If you want to convice yourself about the above syntax, take a look at the PPO file.

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 90
Joined: Wed Nov 07, 2007 08:56 AM
Re: How to clear ordScope()
Posted: Fri Oct 30, 2009 08:35 AM

Do you change index between SetMyFilter() and ClearMyFilter() ?

Posts: 169
Joined: Mon Feb 25, 2008 02:42 AM
Re: How to clear ordScope()
Posted: Fri Oct 30, 2009 11:52 AM
Sir ! Try this..

:-) not work

Code (fw): Select all Collapse
function test()

use detail
index on code tag code to detail

for i := 1 to 100
     detail->(dbappend())
     detail->code   := "001"
     detail->regno := "001"+alltrim(str(i,3))
next

for i := 1 to 100
     detail->(dbappend())
     detail->code   := "002"
     detail->regno := "002"+alltrim(str(i,3))
next

detail->(dbSetOrder("code"))
detail->(ordScope(0,"001"))
detail->(ordScope(1,"001"))
do while !detail->(eof())
    ?detail->regno
    detail->(dbSkip())
enddo

...will display all code with "001"

detail->(ordScope(0,nil))
detail->(ordScope(1,nil))

detail->(dbGotop())
detail->(dbSeek("002"))
... not found.. why ?

Regards
Fafi
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: How to clear ordScope()
Posted: Fri Oct 30, 2009 02:20 PM
Fafi,

Your code works fine here.

James

Code (fw): Select all Collapse
// Purpose: Test ordScope(n,nil) clearing the scope

#include "fivewin.ch"

function test()

local i

local aDbf:={}
aadd( aDbf, { "CODE", "C", 3, 0 } )
aadd( aDbf, { "REGNO", "C", 6, 0 } )
dbcreate( 'DETAIL.DBF', aDbf, )

use detail
index on code tag code to detail

for i := 1 to 5
     detail->(dbappend())
     detail->code   := "001"
     detail->regno := "001"+alltrim(str(i,3))
next

for i := 1 to 5
     detail->(dbappend())
     detail->code   := "002"
     detail->regno := "002"+alltrim(str(i,3))
next


//...will display all code with "001" only
detail->(dbSetOrder("code"))
detail->(ordScope(0,"001"))
detail->(ordScope(1,"001"))
detail->(dbgotop())
do while !detail->(eof())
    ?detail->regno
    detail->(dbSkip())
enddo

// Clear scopes
detail->(ordScope(0,nil))
detail->(ordScope(1,nil))

detail->(dbSeek("002"))

msgInfo( detail->(found()) ) // returns .t.

return nil
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10

Continue the discussion