Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Descending indexes 1

Status
Not open for further replies.

trikertom

Technical User
Aug 14, 2006
5
US
I am using an aftermarket index driver. I need to create a descending date index. In clipper they had a option on index on to do this, but it is not supported with this driver. I have written it programatically in the past but I do not remember how I did it, any suuugestions where to start?????
 
Pick a date a long way in the future and make the order work like this

Code:
INDEX ON STR(CTOD("12/12/2099")-MyDateField,8,0) TAG MyTagName

You might need to consider the date formatting!

Regards

Griff
Keep [Smile]ing
 
Don't rule out the DESCEND() function either!

HTH
TonHu
 
Thank you much. I was thinking it was something simple, but I got a little rusty with my programming since I only do it about once a month or so.
 
Trinkertom,

All of those ideas are good and should work. You could also break out the pieces of the date and subtract them from 9999 for the year or 99 for the day and month which will get you to the same place that Griff is suggesting, only needed if there is some conflict going on. The cleanest way is to use the descend function as TonHu suggests.

Jim C.
 
I *forgot* the descending function - as I do most of my work in VFP and it doesn't have one !

B-(

Regards

Griff
Keep [Smile]ing
 
Griff,

It's all good. I'm still stuck in Clipper 5.2e, I came in with Clipper and I'll probally go out with Clipper.

Jim C.
 

Griff,

I *forgot* the descending function - as I do most of my work in VFP and it doesn't have one !
Guess what? It does! At least versions 6.0-9.0.

Code:
DESCENDING() Function

Returns a logical value that indicates whether an index tag was created with the DESCENDING keyword or whether the DESCENDING keyword was included in USE, SET INDEX, or SET ORDER.

[b]Syntax[/b]

DESCENDING[i]([CDXFileName,] nIndexNumber [, nWorkArea | cTableAlias])[/i]

Yes, I know, I didn't remember it, too, I don't use it in VFP; I just checked the Help. I cannot find it in the old FoxPro (2.0?) manual, though. And I don't remember it from Clipper, too, since the last one I used was Clipper Summer'87 some 12 or more years ago (was it there, in '87 version?).


 
It's not the same Stella

In Clipper you could apply DESCENDING() to anything, in VFP an index is either ASCENDING or DESCENDING - the WHOLE index.

In Clipper you could play a little:

Code:
index on MyFirstField+DESCENDING(MySecondField)+MyThirdField ...

I don't *think* you can do that in VFP... can you?

B-)

Regards

Griff
Keep [Smile]ing
 

I don't know.
I've never tried.
According to the description in Help, probably you can't.
But for that matter, I didn't remeber what you could do with it in Clipper - or even that it existed. (I said it was long ago.) Thanks for the refresher - good example.

 
I used griffmg's suggestion and it worked perfectly. I had used it before 15 years ago but forgot it. I use the Success index drivers so descend() does not work. The indexes are very compact and fast with this addin, and it has never been a problem.
I am with jcreamerII on Clipper. I have used it from inception and only maintain my own Clipper programs, so no need to change.
I have VFP that I am trying to learn, but it is radically different in a lot of respects. I have played with C++ some over the years, but always fall back on good ol' Clipper!

Thanks for everyones help. Tom
 
Good luck to you Tom.

I do a LOT of my work in VFP 5/6/9 now, it is very good indeed and well worth making the move for.

Lots of help on Tek-Tips with it too.

Regards

Griff
Keep [Smile]ing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top