更新时间:2021-12-01 04:58:13
该系统演示了怎样用VSL从数组读取字符串,它是习题4的逆过程。
void main()
{
// Array where we will put the strings that will be read.
ArrayString arrayString;
// String as temporary buffer.
String tmp;
// Loop to read each array's cell.
for (int c = 0; c < myarray.GetColumnCount(); ++c) {
for (int r = 0; r < myarray.GetRowCount(); ++r) {
// First we get the size of the string at pos (r, c)
// (zero included)
int lengthToRead = myarray.GetElementStringValue(r, c, null);
// Then we resize the string before reading the array.
tmp.Resize(lengthToRead-1);
// At last, we can read the string.
// Note that 3rd parameter of GetElementStringValue is a str
// and not an String.
myarray.GetElementStringValue(r, c, tmp.Str());
// We keep the read string in our array.
arrayString.PushBack(tmp);
}
}
// We can do what we want with these strings.
int stringNb = arrayString.Size();
for (int i = 0; i < stringNb; ++i) {
bc.OutputToConsole(arrayString[i].Str());
}
}
现在可以去看看Virtools Minisite
中提供更多的VSL技术性样例,位置在Dev的文档文件夹下 /CMOS/TechnicalSamples/VSL/Samples/.。