How to clear ordScope()

How to clear ordScope()

Postby fafi » Thu Oct 29, 2009 6:03 am

Hi.. Greeting From Indonesia

Code: Select all  Expand view

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

Re: How to clear ordScope()

Postby Loach » Thu Oct 29, 2009 8:39 am

Hello, Fafi !
It has to work!
But you miss ")" in the end of
Code: Select all  Expand view
detail->(ordScope(0,NIL))
Best regards!
Sergey (Loach) Abelev
fwh 9.04/xHarbour 1.2.1 (Rev. 6406)/Bcc55
Loach
 
Posts: 41
Joined: Thu Dec 22, 2005 7:39 am
Location: Gomel, Belarus

Re: How to clear ordScope()

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

Re: How to clear ordScope()

Postby Loach » 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: Select all  Expand view

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

Re: How to clear ordScope()

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

Re: How to clear ordScope()

Postby Loach » 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: Select all  Expand view

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

Re: How to clear ordScope()

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

Re: How to clear ordScope()

Postby Enrico Maria Giordano » Thu Oct 29, 2009 2: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
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: How to clear ordScope()

Postby James Bott » Thu Oct 29, 2009 4:28 pm

From the ord.ch file:

Code: Select all  Expand view
#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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: How to clear ordScope()

Postby Patrizio » Fri Oct 30, 2009 8:35 am

Do you change index between SetMyFilter() and ClearMyFilter() ?
Patrizio
 
Posts: 90
Joined: Wed Nov 07, 2007 8:56 am
Location: Italy

Re: How to clear ordScope()

Postby fafi » Fri Oct 30, 2009 11:52 am

Sir ! Try this..

:( not work

Code: Select all  Expand view

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

Re: How to clear ordScope()

Postby James Bott » Fri Oct 30, 2009 2:20 pm

Fafi,

Your code works fine here.

James

Code: Select all  Expand view
// 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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 87 guests