动态 LotusScript 多维数组
我只是做了一些令人讨厌的代码,我想,而不是使用三个动态数组,如下所示:
dim x() as string, y() as string, z() as string
拥有一个 3 维动态数组会更好。 但; 帮助和我摸索的实验并没有揭示定义它们的方法。
这不起作用:
dim x()() 或 dim(,2) 或 dim(,)
有人有什么想法吗?
I was just doing some yicky code and I thought, instead of using three dynamic arrays, as such:
dim x() as string, y() as string, z() as string
It will be nicer to have a 3 dimensional dynamic array. But; the help and my fumbling experiments has not revealed the method of defining them.
This does not work:
dim x()() or dim(,2) or dim(,)
Any ideas anyone?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用列表而不是数组。
这是完全动态的,并以字符串作为索引。 列表不能包含列表,但列表可以包含对象,因此您可能想要这样做,
这样您就永远不需要 REDIM 保留。 forall 可以让你省力地循环遍历一个列表
You could use lists instead of arrays.
That is fully dynamic and takes a string as index. List can't contain lists, but lists can contain objects, so you might want to do
This way you never need to REDIM preserve. A forall loops you savely through a list
无论维数有多少,动态数组都以相同的方式声明(LotusScript 中的数组最多可以有 8 个维度)。 根据您的示例,我认为它是您想要的二维数组,其中第一维仅限于三个条目。
如果您首先将数组声明为:
然后您可以根据以下示例指定边界:
如果您稍后需要扩大数组(并保留所有值),您可以这样做:
请记住,只有边界一旦设置了数组的维数,最后一个维度的值就可以更改。
A dynamic array is declared the same way regardless of the number of dimensions (arrays in LotusScript can have up to 8 dimensions). According to your example I think it is a two dimensional array you want, where the first dimension is limited to three entries.
If you first declare the array as:
You can then specify bounds according to the following example:
And if you need to enlarge the array later (and keep all the values) you can do it like this:
Please keep in mind that only the bounds of last dimension can be changed once the number of dimensions of the array has been set.