StringConcatenate
StringConcatenate
数据的字串符形式通过并且返回常规字符串大小。 参量可以为任意类型。通过参量的总数不得少于2字符或超过64个字符。
int StringConcatenate(
string& string_var, // 要形成的字符串
void argument1 // 任何简单类型的第一参量
void argument2 // 任何简单类型的第二参量
... // 任何简单类型的下一个参量
);参量
- string_var
[out] 字符串作为串联结果能够形成。
- argumentN
[in] 逗号分离值,从2-63任意简单类型参量。
返回值
返回字符串长度,通过参量串联转变成字符串类型而形成,根据与 Print() 和 Comment()相同的规则把参量转变成字符串。与打印不同,结果字符串串联参量并不能被空间分开。
示例:
void OnStart()
{
//--- 声明和定义参与连接的变量
string text="";
string text1="This script shows how the StringConcatenate() function works.\n";
string text2="This is the second line, at the end of which there is a line break control code.\n";
string text3="This is line number ";
int num3=3;
string text31=", the number of which is entered into the function as a separate parameter.";
string textN="\n";
string text4="This is line number 4, preceded by a separate parameter with a line break code.";
int length=StringConcatenate(text, text1, text2, text3, num3, text31, textN, text4, "\nLine 5 includes a real number: ", 0.12345);
Print(text, "\nLength of the resulting string = ", length);
/*
结果
This script shows how the StringConcatenate() function works.
This is the second line, at the end of which there is a line break control code.
This is line number 3, the number of which is entered into the function as a separate parameter.
This is line number 4, preceded by a separate parameter with a line break code.
Line 5 includes a real number: 0.12345
Length of the resulting string = 358
*/
}另见