I am using DBFCDX. How can I process a table with multiple orders like SQL ORDER BY ... statement with a DBF table, where all sorting keys will be INDEXES of the table (CDX).
Thanks.
Moderator: Rathinagiri
Hi Sudip, how are you ?sudip wrote:Hello All,
I am using DBFCDX. How can I process a table with multiple orders like SQL ORDER BY ... statement with a DBF table, where all sorting keys will be INDEXES of the table (CDX).
Thanks.
Code: Select all
CustCode
BillDt
BillNo
Here first it is sorted with CustCode. Within CustCode - BillDt and within BillDt, BillNoWell, you haven't time for reading whole example; so this is a little pseudo code for your convenience.sudip wrote: Ok, regarding my query, I am working on a project with DBFCDX where user can check anytype of sort order (yes, it will be multiple and one with in another) for viewing or printing.
Code: Select all
REQUEST DBFCDX
* ( say name of you .dbf is [b]CustBill[/b] )
use CustBill
* >>> rutine for FIRST indexing :
* assuming "CustBill.CDX" dosen't exist
OrdCreate( "CustBill.CDX", ; // name of .cdx is same of table (a good habit)
"Customer", ; // index "tag"
"CustCode",; ; // key field (character)
{|| CustCode } ) ) // key code block (for speed)
OrdCreate( "CustBill.CDX", ; // using an existing .cdx name means "add this index too same index file"
"BillDate", ; // index "tag"
"BillDt",; ; // key field (character)
{|| BillDt } ) ) // key code block (for speed)
OrdCreate( "CustBill.CDX", ; // third index (tag) in the same same index file
"BillNumb", ; // index "tag"
"BillNo",; ; // key field (character)
{|| BillNot } ) ) // key code block (for speed)
* using with index (.cdx):
use CustBill index CustBill
OR : if AUTOPEN is ON:
use CustBill
* >>> Selecting/Changing an index order (tag)
* ( as jucar_es mentioned: )
OrdSetFocus("Customer") // first tag: Customer
...
OrdSetFocus("BillDate") // 2.nd tag: BillDate
...
OrdSetFocus("BillNumb") // 3.th tag: BillNumb
* ...
** that is all !
* ................
Code: Select all
SELECT CustCode, BillDt, BillNo, NetAmt FROM Bill ORDER BY CustCode, BillDt, BillNoCode: Select all
CustCode BillDt BillNo NetAmt
-------- -------- ------ ---------
xxxxxxx 01/04/11 1234 100000.00
xxxxxxx 01/04/11 1235 345355.00
xxxxxxx 02/04/11 1111 43324.00
xxxxxxx 02/04/11 1212 434324.00
yyyyyyy 01/04/11 1000 100000.00
yyyyyyy 02/04/11 1245 999999.00
(dates in dd/mm/yy format)
Code: Select all
REQUEST DBFCDX
IF FILE( "Bill.CDX" )
ERASE Bill.CDX
ENDIF
USE BILL VIA DBFCDX
OrdCreate( "Bill.CDX", "Customer", "CustCode + DTOS( BillDt ) + STR( BillNo, 5 )",{|| CustCode + DTOS( BillDt ) + STR( BillNo, 5 ) } )
GO TOP
cCustList := ''CustCode BillDt BillNo NetAmt" + CRLF + "-------- -------- ------ ---------"
DO WHILE .NOT. EOF()
cCustList += CustCode + " " + DTOC( BillDt ) + STR( BillNo,8 ) + TRANSFORM( NetAmt, "999,999,999.99") + CRLF
SKIP
ENDDO
Code: Select all
select a
use bill as custcode index custcode
select b
use bill as billdt index billdt
select c
use bill as billno index billno
SELECT A
do while ! eof()
SELECT B
set filter to CUSTCODE = A->CUSTCODE
go top
do while ! eof()
select C
SET FILTER to CUSTCODE = A->CUSTCODE .and. BILLDT = B->BILLDT
do while ! eof()
? CustCode, BillDt, BillNo, NetAmt
skip
enddo
select B
skip
enddo
select custcode
skip
enddo