Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is this a Y2K problem?
Message
De
03/01/2000 11:51:05
 
 
À
03/01/2000 11:13:22
John Baird
Coatesville, Pennsylvanie, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00311693
Message ID:
00311724
Vues:
21
>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
>
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform