Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Warning: Square brackets as string delimiters
Message
De
11/12/2007 16:20:42
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
11/12/2007 13:38:26
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01274862
Message ID:
01274943
Vues:
7
>Recently I have seen a lot of people are using square brackets as string delimiters. That made me think most of the community isn;t aware of this fact.
>When you use square brackets and there is #define/#include in scope those strings might end with something very different than you expected. ie:
>
>
>#define error 1
>
>? 'An error has occurred'
>? [An error has occurred]
>
>Bottomline: Use single or double quotes as string delimiters unless you know what you're doing with square brackets.
>Cetin

And the reason for this behavior, IMO, is the decision to have the same brackets as array index delimiters. So...
#define hName   1
#define hType    2
#define hLen     3
#define hDecimals   4

aFields(aFF)
?aff[1, hName], aff[1, hType], ...
This simply HAS to work. One of the compelling reasons for having #define directive was the replacement of numeric indexes into arrays with #defined named constants. Unfortunately, the {} brackets are used for something else (macros, direct-to-printer entities) so we're stuck with only three different pairs of string delimiters - and if you use [...], the parser doesn't really care whether they are used as string delimiters or array index delimiters. Though it could (it could just check the last character before [, if part of variable, only then it's an array), but too late now.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform