set Filter to with set Relation to not work for "ADS&qu

set Filter to with set Relation to not work for "ADS&qu

Postby kokookao2007 » Wed Aug 01, 2007 9:28 am

hi all:

"Set Filter to" with "Set Relation to" not work for RDD "ADS",
same source work fine for RDD "DBFCDX" .

*******************
LOCAL cSALSMAN:="TIM",cCOND

cCOND:="SAL->SALSMAN="+"'"+cSALSMAN+"'"

USE SAL INDEX SAL_NO NEW SHARE // INDEX ON SNO

USE SAL1 INDEX SAL1_DT NEW SHARE
SET RELATION TO SAL1->SNO INTO SAL

SET SCOPE TO dDT1,dDT2
SET FILTER TO &cCOND // ERROR FILTER FOR "ADS" , BUT WORK FINE FOR "DBFCDX"
GO TOP

BROWSE()
********************

Anyone Know how ?



Best Regards

kokoo
User avatar
kokookao2007
 
Posts: 59
Joined: Thu May 17, 2007 8:27 am

Re: set Filter to with set Relation to not work for "AD

Postby R.F. » Wed Aug 01, 2007 5:08 pm

Kokoo:

I think I explained it to you in comp.lang.xharbour newsgroup, but here it goes again anyway:

ADS is an EXTERNAL program to your application, so, you cannot use anything related to your program to indicate filters, relations or indexes.

I mean, you cannot use alias, variables or used defined functions in the ADS or RDD related functions or comands. in order to set relations or filters, because ADS CANNOT go into your program code or memory and "inspect" the values of such variables.

kokookao2007 wrote:LOCAL cSALSMAN:="TIM",cCOND

cCOND:="SAL->SALSMAN="+"'"+cSALSMAN+"'"


The previos expression is not valid, if you are going to use it with ADS you cannot use the "SAL" alias, because ADS cannot know what is the value of "SAL" (this is an internal pointer of your application), so, the right expression is:

Code: Select all  Expand view  RUN
LOCAL cSALSMAN:="TIM",cCOND                             
                                                       
cCOND:="SALSMAN="+"'"+cSALSMAN+"'"                 



This:

Code: Select all  Expand view  RUN
USE SAL  INDEX SAL_NO NEW SHARE     // INDEX ON SNO     
                                                       
USE SAL1 INDEX SAL1_DT NEW SHARE                       
SET RELATION TO SAL1->SNO INTO SAL                     
SET SCOPE TO dDT1,dDT2                                 


This can be valid if you want the relation be handled by the client (it could be slow).

And the problem comes here:

Code: Select all  Expand view  RUN
SET FILTER TO &cCOND   // ERROR FILTER FOR "ADS" , BUT WORK FINE FOR "DBFCDX"
BROWSE()   
GO TOP                                                 


As I explained to you in the xharbour news group, all the filtering stuff MUST be established in a TEXTUAL FORM, since the cCOND expression is wrong form the begining, it will sure crash when comming to this point.

This is the right way:

Code: Select all  Expand view  RUN
cCond := cCOND:="SALSMAN="+"'"+cSALSMAN+"'"                 
bCond := "{||"+cCond+"}"
DBSETFILTER(&bCond, cCond)
GO TOP
BROWSE()                                               


Remember, ADS is an EXTERNAL programm running out of the cast of your application. ADS doesn't know anything about your programm enviroment and it doesn't have anyway to know about it.
Saludos
R.F.
R.F.
 
Posts: 840
Joined: Thu Oct 13, 2005 7:05 pm

Postby kokookao2007 » Thu Aug 02, 2007 1:16 am

hi Rene :

Thank you for help Again.

In this sample. there is no field "salsman" define in sal1.dbf .

Code: Select all  Expand view  RUN
cCOND:="SAL->SALSMAN="+"'"+cSALSMAN+"'"
edit to :
cCOND:="SALSMAN="+"'"+cSALSMAN+"'"
// Can not work  , SAL1->SALSMAN==>no such field


What I edit :
1)add field "salsman" to sal1.dbf
2)Replace Sal->Salsman to Sal1->Salsman for scope condition (by Set relation to)
3)now cCOND:="SALSMAN="+"'"+cSALSMAN+"'" or cCOND:="SAl1->SALSMAN="+"'"+cSALSMAN+"'" Can be work

Code: Select all  Expand view  RUN
SOURCE CODE:

LOCAL cSALSMAN:="TIM",cCOND


USE SAL INDEX SAL_NO NEW SHARE // INDEX ON SNO
cCOND:="SAL->SALSMAN="+"'"+cSALSMAN+"'"

SET FILTER TO &cCOND

USE SAL1 INDEX SAL1_DT NEW SHARE

*ADD FIELD SALSMAN FIRST

SET RELATION TO SAL1->SNO INTO SAL
SET SCOPE TO dDT1,dDT2
GO TO
DO WHILE ! EOF()

   SAL1->(RLOCK())
   SAL1->SLASMAN:=SAL->SALSMAN
   SAL1->(DBUNLOCK())
   SKIP
ENDDO
SET RELATION TO

SAL->(DBCLOSEAREA())

SELE SAL1
cCOND:="SAL1->SALSMAN="+"'"+cSALSMAN+"'"
SET FILTER TO &cCOND
...
...



Any best solution not to edit struct sal1.dbf for both Rdd "dbfcdx" and "ADS" ?

Best Regards

kokoo
User avatar
kokookao2007
 
Posts: 59
Joined: Thu May 17, 2007 8:27 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 36 guests