How to clear ordScope()

Post Reply
User avatar
fafi
Posts: 169
Joined: Mon Feb 25, 2008 2:42 am

How to clear ordScope()

Post by fafi »

Hi.. Greeting From Indonesia

Code: Select all

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
Last edited by fafi on Thu Oct 29, 2009 10:00 am, edited 1 time in total.
Loach
Posts: 41
Joined: Thu Dec 22, 2005 7:39 am
Location: Gomel, Belarus

Re: How to clear ordScope()

Post by Loach »

Hello, Fafi !
It has to work!
But you miss ")" in the end of

Code: Select all

detail->(ordScope(0,NIL))
Best regards!
Sergey (Loach) Abelev
fwh 9.04/xHarbour 1.2.1 (Rev. 6406)/Bcc55
User avatar
fafi
Posts: 169
Joined: Mon Feb 25, 2008 2:42 am

Re: How to clear ordScope()

Post by fafi »

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
Loach
Posts: 41
Joined: Thu Dec 22, 2005 7:39 am
Location: Gomel, Belarus

Re: How to clear ordScope()

Post by Loach »

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: Select all

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
User avatar
fafi
Posts: 169
Joined: Mon Feb 25, 2008 2:42 am

Re: How to clear ordScope()

Post by fafi »

Thank's Mr. Loach

I added SET SCOPE TO

It's work now...

Thank's so much

Regards
Fafi
Loach
Posts: 41
Joined: Thu Dec 22, 2005 7:39 am
Location: Gomel, Belarus

Re: How to clear ordScope()

Post by Loach »

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: Select all

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
User avatar
Richard Chidiak
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France
Contact:

Re: How to clear ordScope()

Post by Richard Chidiak »

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
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: How to clear ordScope()

Post by Enrico Maria Giordano »

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
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: How to clear ordScope()

Post by James Bott »

From the ord.ch file:

Code: Select all

#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
Patrizio
Posts: 90
Joined: Wed Nov 07, 2007 8:56 am
Location: Italy
Contact:

Re: How to clear ordScope()

Post by Patrizio »

Do you change index between SetMyFilter() and ClearMyFilter() ?
User avatar
fafi
Posts: 169
Joined: Mon Feb 25, 2008 2:42 am

Re: How to clear ordScope()

Post by fafi »

Sir ! Try this..

:( not work

Code: Select all

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
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: How to clear ordScope()

Post by James Bott »

Fafi,

Your code works fine here.

James

Code: Select all

// 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
Post Reply