Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Slim Code - List of Shortcuts?
Message
De
01/07/2010 12:01:12
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
01/07/2010 11:53:26
Kevin Hickman
The Cadle Company
Ohio, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Novell 6.x
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01471199
Message ID:
01471202
Vues:
81
>Does anyone know where I can find I big list of shortcut functions/coding syntax to help slim down the code making it smaller and/or neater?
>
>For example:
>
>
>IF test = X .or. test = Y .or. test = Z    could be  IF INLIST(test,X,Y,Z) 
>or
>IF LEN(ALLTRIM(test)) = 0  could be IF EMPTY(test)
>
>
>There are always some we either don't know about, or haven't used in a long time and forget about...

I don't know of any specific listing; you may want to compile and publish one. Here are some more.

inlist() immediately reminds me of between().
x >= 1 and x <= 10
* is the same as
between(x, 1, 10)
Closing a table: You can void checking whether it is actually open, with the following short, but somewhat confusing, syntax:
use in select("MyTable")
(On the other hand, you can often avoid closing tables explicitly alltogether, by using private data sessions. But that is not the only reason to use private datasessions.)

Comparing a logical value (this is obvious for some, but many commit this mistake, so I prefer to include it):
IF MyValue = .T.
* is redundant. You can just use:
IF MyValue
Exclusive OR: Visual FoxPro doesn't have an explicit XOR operator.
* You might use:
(a and not b) or (not a and b)
* But the following is much more compact and elegant:
a # b
* Watch out for operator precedence. Comparison operators have a lower order of precedence than logical operators.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform