
字串符类型报告的一组函数。
StringConcatenateStringFindStringGetCharStringLenStringSetCharStringSubstrStringTrimLeftStringTrimRightstring StringConcatenate( ...)
报告的字串符形式通过而且返回。 参数可以为任意类型。通过参数的总数不得胜过64个字符。
作为应用到Print(), Alert() 和Comment()函数的参数依照同样规则传送。从函数参数返回获取的字符串作为连接结果。当字串符接连运用(+)添加时,StringConcatenate() 运行较快而且会存储。
参数:
... - 所有价格值由逗号分开。 它可以是64个参数。
示例:string text;
text=StringConcatenate("Account free margin is ", AccountFreeMargin(), "Current time is ", TimeToStr(TimeCurrent()));// 文本="Account free margin is " + AccountFreeMargin() + "Current time is " + TimeToStr(TimeCurrent())Print(text);int StringFind( string text, string matched_text, void start)搜索子字串符。假使未寻到子字串符,从搜索子字串符开始返回字串符中的位置,或是 -1。
参数:
text - 被搜索的字符串。
matched_text - 需要搜索的字符串。start - 搜索开始索引位置 。示例:string text="迅速的棕色小狗逾越过懒惰的狐狸";
int index=StringFind(text, "小狗逾越", 0);if(index!=16)Print("oops!");int StringGetChar( string text, int pos)从字串符指定位置返回代码。
参数:
text - 字串符。
pos - 取字符的位置 。可以从0 至 StringLen(text)-1。示例:int char_code=StringGetChar("abcdefgh", 3);
// 取出代码 'c' 是 99int StringLen( string text)在字串符中返回代码数。 Returns character count in a string.
参数:
text - 计算字符串长度。
示例:string str="some text";
if(StringLen(str)<5) return(0);string StringSetChar( string text, int pos, int value)在指定位置返回带有更改代码的字串符复本。
参数:
text - 更改的字串符代码。
pos - 字串符种代码的位置。可以从0 至 StringLen(text)。value - 新获得ASCII 代码。示例:string str="abcdefgh";
string str1=StringSetChar(str, 3, 'D');// str1 is "abcDefgh"string StringSubstr( string text, int start, void length)从给出的位置的文本字串符开端提取字串符。
假使或许此函数返回提取字串符的副本,否则返回空字串符。
参数:
text - 将被提取的字串符。
start - 字串符开始索引。可以是自 0 至 StringLen(text)-1。length - 字串符提取的宽度。假使参数值胜过或等于 0 或者参数没有指定,字串符将被提取。示例:string text="迅速的棕色小狗逾越过懒惰的狐狸";
string substr=StringSubstr(text, 4, 5);// 减去字串符是"迅速"单词string StringTrimLeft( string text)在字串符左侧部分函数剪切空间和图表。假使或许函数返回一个剪切的复本。否则返回空字串符。
参数:
text - 左侧剪切的字串符。
示例:string str1=" Hello world ";
string str2=StringTrimLeft(str);// 在剪切str2会是 "Hello World "string StringTrimRight( string text)在字串符右侧部分函数剪切空间和图表。假使或许函数返回一个剪切的复本。否则返回空字串符。
参数:
text - 右侧剪切的字串符。
示例:string str1=" Hello world ";
string str2=StringTrimRight(str);// 在剪切str2 之后会是 " Hello World"