>Gentlemen:
>
>Below is a method of my program that allows changing index order on a grid header click(). This worked fine until today. I am getting calls from all over the country about the "contains unknown command" error.
>
>The error is occuring on the this line:
>
> SET ORDER TO &lcIndexName &lcOrder
>
>IF I change it to
>
> SET ORDER TO (lcIndexName) &lcOrder
>
>it works just fine. Any idea as to what's up?
>
Yep. It's called misuse of macro-expansion. Macro-expansion is neither needed nor desirable where you are simply using it to expand a name - you're giving VFP's interpreter the opprtunity to miscue early and often. Instead of using the macro-expansion operation, use name resolution by encapsulating theings that are names within parentheses - VFP can't misparse the name this way due to embedded delimiters, and it's faster and more reliable as well.
Jim Booth's thread on the 10 most misused VFP constructs was right on the money - misuse of macro expansion is one of the worst culprits, and results in more head-scratching than almost any other part of the language, because programmers make poor assumptions about what;'s actually happening when macro-expansion takes place. If you need to get the command line parser involved in runtime interpretation of the command as a whole, then macro-expansion may be warranted; using it to replace a name at runtime means you've taken the lazy approach to handling the problem without regard for what is needed or desirable.
>
>*************************************************************
>
>LOCAL lcOrder, lcIndexName
>
>SELECT cQuoteList
>WITH this
> IF .cColName = ALLTRIM(tcColName)
> .cColOrder = IIF(.cColOrder = 'DESC', 'ASCEND', 'DESC')
> lcIndexName = .cIndexName
> ELSE
> .cColOrder = 'ASCEND'
> .cColName = ALLTRIM(tcColName)
> lcIndexName = SUBSTR(SYS(2015), 3, 10)
> .cIndexName = lcIndexName
>
> INDEX ON &tcField TO &lcIndexName
> ENDIF
>
> lcOrder = .cColOrder
> SET ORDER TO &lcIndexName &lcOrder
> .LockScreen = .T.
> .grdList.refresh()
> LOCATE
> .LockScreen = .F.
>ENDWITH
>