Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Square brackets
Message
De
26/04/2001 10:56:42
 
 
À
26/04/2001 10:26:04
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Divers
Thread ID:
00500093
Message ID:
00500124
Vues:
18
This message has been marked as a message which has helped to the initial question of the thread.
>A while back, when getting into WebConnect, I found liberal use of square brackets where I had expected to see quotes (single or double). I knew these substituted nicely for parentheses in array coding but was totally surprised by this other usage.
>
>I've played around with these a bit and find them (square brackets) equivalent to quotes of either variety.
>
>Is this a correct conclusion?. . . Is this documented somewhere (a search of MSDN (July 2000) and Hacker's revealed virtually nothing)? . . . Are there things to watch out for?



Most of the time I will use double quotes, but I almost always use square brackets when I have to use quotes (single or double) in the string to improve readness (sp?). For example, I feel that:
cSQLString = "SELECT * FROM Table WHERE field = 'Something'"
is harder to read/less obvious than:
cSQLString = [SELECT * FROM Table WHERE field = 'Something']
Likewise, I prefer to write STRTRAN(m.cVar, ['], ['']) rather than STRTRAN(m.cVar, "'", "''").

It also sometimes make it more obvious what is in the string and what is used to build the string.
cSQLString = [SELECT * FROM Table WHERE field = '] + STRTRAN(m.cVar, ['], ['']) + [']
cSQLString = "SELECT * FROM Table WHERE field = '" + STRTRAN(m.cVar, "'", "''") + "'"
Anytime I build a string that is to be sent to SQLServer, I use the square brackets since I often have to use single quotes like in my first example. Even when I don't have a need for single quotes, I will still use brackets for SQL strings for consistency.

As for things to watch out for, I never found any problem in using square brackets. But, like I said, most of the time I use the double quotes.
Sylvain Demers
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform