When you
have to construct long strings combining different types of data
using many functions in between, it maybe better and easier to use
the "Format()" functions
instead of using "+" signs.
For example, consider the following simple string (assuming that
"sName" is a string
variable containing a name):
'My name is ''+ sName + ' and I am '
+ IntToStr( 16 )
+ ' years old'
' |
Listing #1
: Delphi code. Right click strcc.pas
to download. |
It's better to use "Format()" to achieve the same result, because
it makes it easier to read and format your source code:
Format(
'My name is %s and I am %d years old',
[ sName, 16 ] )
|
Listing #2
: Delphi code. Right click strcc2.pas
to download. |
Of course, "Format()"
can handle many other types of data and format them in many ways, so
be sure to lookup help for it.