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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

set("order") vs. order()

Status
Not open for further replies.

steve4king

IS-IT--Management
Feb 6, 2007
154
US
I'm fixing an issue with some old code:

Code:
select sometable
lcOriginalIndex = set("order")

set order to SomeOtherIndex
**
**do stuff
**
set order to &lcOriginalIndex

Set("order") returns "tag myIndexName of [full path of current cdx file]"

The problem is that if there is a space in my path, fox doesn't like it.. even if it's in quotes.
My fire-from-the-hip fix would be to replace 'set("order")' with 'order()' which will return just "myIndexName".. which is all I need.

However, elsewhere in this program I see that it was originally using 'order()' and at some point was changed to 'set("order")' with the only note for this saying, "&& Save any order set".

I use CDX files, no IDX files, so there is only one index file per table file.

Before I change 12 different files in this project..
Can anyone think of a possible reason for the previous change from 'ORDER()' to 'SET("ORDER")'?

Thanks,


-Stephen
 
The only reason I know of where that would be useful would be when you're using the debugger to verify that the correct table was selected when the tag was stored. I have personally never used 'STORE SET("ORDER") TO ... ', only "STORE ORDER() TO ... ".


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Can anyone think of a possible reason for the previous change from 'ORDER()' to 'SET("ORDER")'?

The only reason I can think of is if the index is descending. In that case, SET("ORDER") is preferable, as it also returns the keyword DESCENDING. In fact, the string it returns is in exactly the format needed for saving and restoring the index information.

However, since you are not interested in saving and restoring the filename, I suggest you go back to using ORDER(). If you omit the second (optional) parameter, it will just give you the tag name, which is exactly what you want. The only problem is that, if the tag might be descending, you would have to also use the DESCENDING() function to determine that.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Ahh, that's probably it Mike.
Code:
lcOriginalIndex = ORDER() + IIF(DESCENDING(),' DESC','')

This should do it then.
Thanks!

-Stephen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top