Visual FoxPro Tips
 
Concatenating Strings
 
Suppose you have a table with firstname and lastname fields and you want to show full name on the screen or in a report. The first expression that comes to mind is like :
 
SELECT TRIM(lastname)+', '+firstname ...
 
Or
 
SELECT ALLT(lastname)+', '+firstname ...
 
However, there is a shorter way:
 
SELECT lastname - (', '+firstname)
 
The '-' is another concatenation operator that removes trailing blanks from the element preceding the operator then joins two elements. Note that there is a difference between using the '-' operator and ALLT in the above example. The latter removes all blanks from last name while the former moves the trailing blanks from last name and adds them to the end of the resulting expression. This is handy if you want the size of the resulting field to be equal to the total size of its elements.
 
This tip is provided to you by Foxy Classes. For more Visual FoxPro tips, click here.
 
 
   
   
Send mail to webmaster@engineerica.com with questions or comments about this web site.
Copyright 2002-2003 Engineerica Systems, Inc.