Luis,
TAG / TAGNO
I dislike the mixture of TAG / TAGNO, and for me the TAGNO, is outdated XBASE from the days of yore. Just do all from a TAG perspective, this is well defined.
DESCENDING
Something is wrong here, the help states
DESCENDING([CDXFileName[, nIndexNumber [, nWorkArea | cTableAlias]]])If I try on a table like
CREATE CURSOR curTest (i1 I)
INDEX ON i1 TAG _i1
?DESCENDING(_i1,'curTest')
SET ORDER TO _I1 descending
?DESCENDING(_i1,'curTest')
it fails on the first DESCENDING
So, if it runs for your code,
i_nm must be a var or a field with a number.
I would rather do ("if .. else" swapped for faster expression and TAG generalized)
Select crMonitorFacturas
lcTag = "I_NM"
If Sys(22,SELECT("crMonitorFacturas")) == m.lcTag
If Descending(TAGNO(m.lcTag),"crMonitorFacturas")
Set Order To (m.lcTag) In crMonitorFacturas Ascending
Else
Set Order To (m.lcTag) In crMonitorFacturas Descending
Endif
Else
Set Order To (m.lcTag) In crMonitorFacturas
Endif
At least this switches for me.
Now you need this as a proc with the TAG as parameter and you are done for any TAG.
Lutz
Aunt Edit says:
Added SELECT() to SYS(22), so you have all commands with the alias/workarea fitting.
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord
Weeks of programming can save you hours of planning.
OffThere is no place like [::1]