ordcondset descending

201 views
Skip to first unread message

Luigi Ferraris

unread,
Jun 13, 2016, 1:19:53 PM6/13/16
to Harbour Users
Hi friends,
I need to create a descending order; I'm using multitag .NTX. This is my (snippet) code
         ::ordCondSet( "!DELETED()", ;
                       {|| !DELETED()}, ;
                       .T., ;
                       /*bWhileCondition*/, ;
                       /*bEval*/, ;
                       /*nInterval*/, ;
                       /*nStart*/, ;
                       /*nNext*/, ;
                       /*nRecord*/, ;
                       /*lRest*/, ;
                       .T. )
         ::ordCreate( ::indexName(), "byBegDate", "wktbgdate", {|| FIELD->wktbgdate }, .F. )


I'm setting the 11th parameter to .T., but it seems it doesn't works (I'm testing my code).
Does Harbour/CLIPPER (.NTX multitag) support parameters over 5th?

I'm able to change the ascending/descending flag at runtime using orddescend, but I want a fixed descending order.

Alternatives using ordxxxxx() commands?

Many thanks in advance, regards
Luigi Ferraris

Maurizio la Cecilia

unread,
Jun 14, 2016, 5:18:42 AM6/14/16
to harbou...@googlegroups.com
Hi Luigi,
I guess the field wktbgdate is date type.
Did you try with a character key expression [ i.e. DToS( wktbgdate ) ] ?
Just to better delineate your problem.

You're using ordCondSet() as a method of some custom table class. Are you sure that the parameters are passed in the same order?

Best regards.
--
Maurizio
--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Luigi Ferraris

unread,
Jun 14, 2016, 12:29:53 PM6/14/16
to harbou...@googlegroups.com
Hi Maurizio
Il 14/06/2016 11.16, Maurizio la Cecilia ha scritto:
> I guess the field wktbgdate is date type.
No, it's a character data type but yes is get/stored as hb_Ttos().
> Did you try with a character key expression [ i.e. DToS( wktbgdate ) ] ?
> Just to better delineate your problem.
>
> You're using ordCondSet() as a method of some custom table class. Are
> you sure that the parameters are passed in the same order?
Yes, because the method do
METHOD ordCondSet( ... ) CLASS xxxxx
IF ::isOpen()
RETURN (::nWorkArea)->(ORDCONDSET(...))
END IF
RETURN .F.

Anyway, I have used another field to test ordering and works fine.
Probably I'm little confused about ordering: I don't know.

This is the data scenario (snippet, only two records, but real data)
RECNO | WKTCODEID | WKTBGDATE
| (8chars) | (17chars)
1 | 00000001 | 20160523083000000
2 | 00000002 | 20160522103000000

Using ordconset (descending) on filed WKTCODEID works fine: I can see
(before) 00000002 and then 00000001
Using ordconset (descending) on filed WKTBGDATE is wrong: I can see
(before) 00000001 and then 00000002

I have used a simple array to ordering (ASORT) WKTBGDATE values and
works fine.

Many thanks for your answer.

Regards
Luigi





Luigi Ferraris

unread,
Jun 15, 2016, 5:28:54 AM6/15/16
to Harbour Users
Hi friends,
I wrote a sample using standard CLIPPER functions in console mode.
I have used all parameters (ie DBCREATE( .T., RDDSETDEFAULT().... ) because in my real scenario these a methods of a class that uses internal stored values.
In attachement, source and .hbp directive I'm using.
Sample create a dbf with multitag .ntx and write 3 records; by default set codePage as ITWIN.
It shows (two loops) datas using different order tag:
- first one (ascending) based on codeId
- second one (descending) based on a string.
Changing values (ie "201605...") to names (ie "luigi") order descending is always wrong.

Is there someone can help me to understand where I'm wrong?

Many thanks in advance
Luigi
test.zip

Luigi Ferraris

unread,
Jun 15, 2016, 6:07:07 AM6/15/16
to Harbour Users
Hi to everyone,
it seems only first order knows must be descending.
If I set descending on first field, the records order (descending) is right.
I can see (first loop that know is descending)
RECNO 3::00000003::.....
RECNO 2::00000002::.....
RECNO 1::00000001::.....


Revised code (related to my sample) to perform previous test is:
    // by code
  (nW)->( ORDCONDSET( "!DELETED()", ;
                       {|| !DELETED()}, ;
                       .T., ;
                       NIL, ;
                       NIL, ;
                       NIL, ;
                       NIL, ;
                       NIL, ;
                       NIL, ;
                       NIL, ;
                       .T. ) )
   (nW)->( ORDCREATE( hb_FnameMerge( hb_DirBase(), cFile, "ntx" ), ;
                      "byCode", ;
                      "wktcodeid", ;
                      {|| FIELD->wktcodeid }, ;
                      .F. ) )

Regards
Luigi

Luigi Ferraris

unread,
Jun 15, 2016, 6:21:09 AM6/15/16
to Harbour Users
Hi,
a corrige related with my previous message: the right order seems /it's just a case.
If I change: "00000001" to "gray", "00000002" to "davis" and "00000003" to "clark" the order is wrong.
Regards
Luigi

zbiant

unread,
Jun 15, 2016, 10:02:36 AM6/15/16
to Harbour Users, luigfe...@gmail.com
Hi Luigi


This is the data scenario (snippet, only two records, but real data)
RECNO | WKTCODEID | WKTBGDATE
       | (8chars)  | (17chars)
   1   | 00000001  | 20160523083000000
   2   | 00000002  | 20160522103000000

Using ordconset (descending) on filed WKTCODEID works fine: I can see
(before) 00000002 and then 00000001
this is OK
Using ordconset (descending) on filed WKTBGDATE is wrong: I can see
(before) 00000001 and then 00000002
and this is OK
try this example oop002.prg


oop002.prg

Teo Fonrouge

unread,
Jun 15, 2016, 10:31:48 AM6/15/16
to Harbour Users
Hi Luigi,

Checking your sample it seems ok and working as expected:

Just note that both indexes created have the record list in the SAME logical order,
so don't you expect to see different order list showed on each index.

The index by 'byCode' field ( not descending ) shows the record list in correct order
The index by 'byBegDate' field ( descending ) shows the record list in correct order:

 1 : '20160523...'
 2 : '20160522...'
 3 : '20160521...'

That is a descending index key value order.


best regards,

Teo

Luigi Ferraris

unread,
Jun 15, 2016, 10:54:40 AM6/15/16
to harbou...@googlegroups.com
Hi guys,
first of all many thanks to everyone


Il 15/06/2016 16.31, Teo Fonrouge ha scritto:
The index by 'byCode' field ( not descending ) shows the record list in correct order
The index by 'byBegDate' field ( descending ) shows the record list in correct order:

 1 : '20160523...'
 2 : '20160522...'
 3 : '20160521...'

That is a descending index key value order.
second one: I must apologize to everyone for my carelessness!!!! aarghhhh!

I was thinking
one thing but I completely lost my mind. My target was: I want see (before) the (record) with the most old date....

so why
I thought about using the descending order?
Maybe I have to stop... :-\

How can be closed and marked as "stupid" this thread ?

Best regards
Luigi

Teo Fonrouge

unread,
Jun 15, 2016, 11:01:31 AM6/15/16
to Harbour Users, luigfe...@gmail.com
Hi Luigi,

Don't worry, also happens to me all time.

But, if you really sorry, then you have to send 1 kg of some excellent italian cheese
to each one on this thread :)


best regards,

Teo

Luigi Ferraris

unread,
Jun 15, 2016, 11:09:43 AM6/15/16
to Teo Fonrouge, Harbour Users
Il 15/06/2016 17.01, Teo Fonrouge ha scritto:
> Hi Luigi,
>
> Don't worry, also happens to me all time.
>
> But, if you really sorry, then you have to send 1 kg of some excellent
> italian cheese
> to each one on this thread :)
>
You are right! It's been a "very expensive" problem for me >:o

Luigi

JoséQuintas

unread,
Jun 15, 2016, 11:56:49 AM6/15/16
to harbou...@googlegroups.com
For descend string keys I use this function:

http://www.harbourdoc.com.br/show.asp?seek=t&key=CPDescend()

Not sure if Descend() continues Clipper compatible, or if now exists a Harbour equivalent function for codepage use.
Without this function, order may be incorrect, when using codepage

José M. C. Quintas
-

Reply all
Reply to author
Forward
0 new messages