OrdScope help

Moderator: Rathinagiri

Post Reply
User avatar
fouednoomen
Posts: 172
Joined: Sun Oct 14, 2012 8:33 am
DBs Used: DBF, MySQL, MariaDB, SQLite, PostgreSQL, Oracle, ODBC
Location: Tunisia
Been thanked: 9 times

OrdScope help

Post by fouednoomen »

Dear All ,

How can I replace this function by OrdScope function

set filter to facture->cod_cli=client->cod_cli .and. facture->mont_fac-facture->avance >0


for information the index file is build as the following

use facture
Index on cod_cli+str(mont_fac-avance) tag xsolde to facture

I try this code but it dos not work

sele facture
SET ORDER TO 1
OrdScope(0,(client->cod_cli+'1'))
OrdScope(1,(client->cod_cli+'99999'))
dbgotop()




Regards

foued

User avatar
danielmaximiliano
Posts: 2508
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Has thanked: 624 times
Been thanked: 140 times
Contact:

Post by danielmaximiliano »

Hi Foued :
I use this way ORDSCOPE .

Code: Select all

/*******************************************************/
Procedure Vencimientosordenar()
/*******************************************************/
cKey  := ""
cKey2 := ""
 ORDSCOPE( TOPSCOPE    , NIL )
 ORDSCOPE( BOTTOMSCOPE , NIL )
 cKey  := DTOS( Vencimientos.FECHA1.value)
 cKey2 := DTOS( Vencimientos.FECHA2.value)
 dbgotop()  // move the record pointer for the filter to take effect
 ordscope(TOPSCOPE   , "&cKey"  )  // set top scope
 ordscope(BOTTOMSCOPE, "&cKey2" )  // set bottom scope
 Vencimientos.grid_1.refresh
Return
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO

User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Has thanked: 411 times
Been thanked: 120 times
Contact:

Post by esgici »

fouednoomen wrote:...

How can I replace this function by OrdScope function

set filter to facture->cod_cli=client->cod_cli .and. facture->mont_fac-facture->avance >0


for information the index file is build as the following

use facture
Index on cod_cli+str(mont_fac-avance) tag xsolde to facture

I try this code but it dos not work

sele facture
SET ORDER TO 1
OrdScope(0,(client->cod_cli+'1'))
OrdScope(1,(client->cod_cli+'99999'))
dbgotop()
...
Hi Foued

Using STR() without length (second) parameter, may cause some problems while building an index key and keys of an index should be same length.

So something like this may help you :

~~~~~~~~~~~~

nLengthOfMFacAv := 5

use facture
Index on cod_cli+str(mont_fac-avance,nLengthOfMFacAv) tag xsolde to facture

sele facture
SET ORDER TO 1
OrdScope(0,(client->cod_cli+PADL( '1', nLengthOfMFacAv ) )) // or SPACE(4) + "1"
OrdScope(1,(client->cod_cli+'99999'))
dbgotop()

~~~~~~~~~~~~~~

And, if we have some sample data for your tables helping you may be more easy.

Regards
Viva INTERNATIONAL HMG :D

User avatar
fouednoomen
Posts: 172
Joined: Sun Oct 14, 2012 8:33 am
DBs Used: DBF, MySQL, MariaDB, SQLite, PostgreSQL, Oracle, ODBC
Location: Tunisia
Been thanked: 9 times

Post by fouednoomen »

Hi Esgici

Many thanks for your prompt replay

I look for this solution from 3 days


Regards

Foued

User avatar
dhaine_adp
Posts: 457
Joined: Wed Aug 06, 2008 12:22 pm
Location: Manila, Philippines
Been thanked: 3 times

Post by dhaine_adp »

Hi Foued,

You can also used these commands:

Code: Select all

USE EMPLOYEE ALIAS EMPLOYEE NEW VIA RDDSETDEFAULT()
INDEX ON ID Tag ID TO Employee
INDEX ON DOB Tag DOB TO Employee

// At later part or another module of your code you can for example:
USE EMPLOYEE ALIAS EMPLYEE NEW
ORDLISTADD( "Employee" ) 
ORDSETFOCUS( "ID", "Employee")
To adopt your code you should do:

Code: Select all

use facture
Index on cod_cli+str(mont_fac-avance) tag xsolde to facture

** declare these variables below at the top of your function
PRIVATE cTopBound 
PRIVATE cLowBound

sele facture
SET ORDER TO 1
cTopBound := client->cod_cli + "1"
cLowBound := client->cod_cli + '99999'
OrdScope(0, "&cTopBound" )
OrdScope(1, "&cLowBound" )
dbgotop()
Regards,

Danny
Regards,

Danny
Manila, Philippines

Post Reply