Game Development Community

Advantages of SPC?

by Justin Mosiman · in Torque Game Engine · 05/09/2006 (11:10 am) · 3 replies

I know that the differences are probably insignificant, but what are the differences between using SPC and " " within TorqueScript?

For example, are there any differences at all between:

echo("hi" SPC %name);
and
echo("hi " %name);

#1
05/09/2006 (11:16 am)
SPC will concatenate the two strings together and add a space in the middle. So "hi" SPC %name create a string like "hi eric", where as "hi" %name is two separate objects, "hi" "eric". Does that help?
#2
05/09/2006 (11:21 am)
That does make sense, so they are two different things. Thanks!
#3
05/09/2006 (11:24 am)
I think you would actually have to have this for the second one
echo("hi " @ %name);
using the @ to concatenate the strings. In the case of strings where you can type in the space, it may be shorter to use the @.

If you are concatenating several variables and needed spaces then you would have
echo(x @ " " @ y @ " " @ z);
or
echo(x SPC y SPC z);

The second one is shorter and appears cleaner.