动态 LotusScript 多维数组

发布于 2024-07-16 11:39:58 字数 227 浏览 9 评论 0原文

我只是做了一些令人讨厌的代码,我想,而不是使用三个动态数组,如下所示:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

您可以使用列表而不是数组。

Dim x list as String

这是完全动态的,并以字符串作为索引。 列表不能包含列表,但列表可以包含对象,因此您可能想要这样做,

Public Class ListContainer
   Public level2 List as String
End Class

这样您就永远不需要 REDIM 保留。 forall 可以让你省力地循环遍历一个列表

You could use lists instead of arrays.

Dim x list as String

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

Public Class ListContainer
   Public level2 List as String
End Class

This way you never need to REDIM preserve. A forall loops you savely through a list

回眸一笑 2024-07-23 11:40:01

无论维数有多少,动态数组都以相同的方式声明(LotusScript 中的数组最多可以有 8 个维度)。 根据您的示例,我认为它是您想要的二维数组,其中第一维仅限于三个条目。

如果您首先将数组声明为:

Dim x() As String

然后您可以根据以下示例指定边界:

Redim x( 0 To 2, 0 To 9 ) ' A two dimensional array

如果您稍后需要扩大数组(并保留所有值),您可以这样做:

Redim Preserve x( 0 To 2, 0 To 99 )

请记住,只有边界一旦设置了数组的维数,最后一个维度的值就可以更改。

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:

Dim x() As String

You can then specify bounds according to the following example:

Redim x( 0 To 2, 0 To 9 ) ' A two dimensional array

And if you need to enlarge the array later (and keep all the values) you can do it like this:

Redim Preserve x( 0 To 2, 0 To 99 )

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文