如何在Powerbuilder中创建用户对象数组?
我正在尝试将曾经嵌入在窗口上的视觉用户对象转换为不同窗口(同一包)中动态创建的视觉用户对象。
我遇到的问题是,如果不获取空引用或一遍又一遍地重用同一对象,我似乎无法创建这些对象的数组。
目前,当用户需要新的数组元素时:
long ll_count
ll_count = UpperBound(iuo_backorders[])
iuo_backorders[ll_count+1] = uo_backorder
lb_ok = iuo_backorders[ll_count+1].init('w_backorder_popup', '', '', '', 'd_backorder_popup', sqlca, useTransObj())
这会一次又一次地重用相同的 uo_backorder 。
使用:iuo_backorders[ll_count+1] = create uo_backorder
返回空对象引用。
用户对象包含在另一个窗口中(我认为),所以我不确定是否需要将 uo_ 命令移到 PBL 中它自己的文件中,或者以某种方式更改引用(新窗口是原始窗口的子窗口) ,但不确定这与 uo_ 有何关系)
所有功能都已在 uo_ 中,我只需要能够弄清楚
A) 如何动态创建可视用户对象
B)< /strong> 然后如何创建这些对象的数组。
I am trying to convert a VISUAL USER OBJECT that was once embedded on a window, into a DYNAMICALLY CREATED VISUAL USER OBJECT in a different window (same package).
The problem I'm getting is I can't seem to be able to create an array of these objects without getting null references or reusing the same object over and over.
At the moment, when a user needs a new array element:
long ll_count
ll_count = UpperBound(iuo_backorders[])
iuo_backorders[ll_count+1] = uo_backorder
lb_ok = iuo_backorders[ll_count+1].init('w_backorder_popup', '', '', '', 'd_backorder_popup', sqlca, useTransObj())
This reuses the same uo_backorder again and again.
Using: iuo_backorders[ll_count+1] = create uo_backorder
returns null object references.
The user object is contained within another window (I think), so I'm not sure if I need to move the uo_ commands out into it's own file in the PBL, or somehow change the references (new window is a child of the original, but unsure how that pertains to uo_)
All the functionality is already in the uo_, I just need to be able to work out
A) how to dynamically create a visual user object
B) how to then create an array of these objects.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要实例化一个视觉对象,您需要:
或者
我希望您能够为您的 userobjectvar 使用 iuo_backorders[ll_count+1] ,但如果没有,只需使用单个用户对象变量并将其分配给数组元素实例化后。
祝你好运,
特里。
To instantiate a visual object, you need:
or
I'd expect that you'd be able to use iuo_backorders[ll_count+1] for your userobjectvar, but if not, just use a singular user object variable and assign it to the array element after it's instantiated.
Good luck,
Terry.
PowerBuilder 试图巧妙地告诉您您使用了错误的方法。当您在运行时通过 OpenUserObject 创建可视控件时,您必须管理为每个控件提供 x,y 坐标的布局。另外,如果您想要多个相同的控件,则必须使用 Terry 发布的第二种形式的 OpenUserObject。如果您想要制作类似向导之类的东西并堆叠用户对象,那么这很好,但在代码中布局对象则不适用于 Disco。在 PowerBuilder 中,只要您想要显示多个内容,尤其是可变数量的内容,您就应该使用 DataWindow 控件。在您的情况下,您需要将 uo_backorder 中的功能移动到非可视对象,并在数据窗口中显示数据。如果所有数据(状态)都在数据窗口的行中,则所有行只需要一个 nvo。
PowerBuilder is subltly trying to tell you that you're using the wrong approach. When you create visual controls at runtime via OpenUserObject, you have to manage the layout supplying the x,y coordinates for each control. Also if you want more than one of the same control you have to use the second form of OpenUserObject that Terry posted. This is fine if you want to make something like a Wizard and stack the user objects, but otherwise laying out objects in code went out with Disco. In PowerBuilder, as soon as you want to display more than one of something, especially a variable number of something, you should be reaching for a DataWindow control. In your case, you need to move the functionality that is in uo_backorder to a non-visual object, and display the data in a DataWindow. If all of the data (state) is in the DataWindow's rows, you only need one nvo for all of the rows.