如何在函数中传递结构数组啊?

pufan 2002-05-28 10:41:18
谁能告诉我,我找遍了所有的帖子也没有找到。
...全文
151 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangsw 2002-05-29
  • 打赏
  • 举报
回复
函数中的变量定义只在函数内有效!!
pufan 2002-05-28
  • 打赏
  • 举报
回复
我实在事件中写的,错误代码为:
c0014 undifined variable: s_1

另外在函数中写已经通过了,但为什么不能在事件中写呢?
chinalht 2002-05-28
  • 打赏
  • 举报
回复
你定义的没问题啊,把出错提示帖上来看看。
是不是名称写错了啊。
yuanbo824 2002-05-28
  • 打赏
  • 举报
回复
和普通参数相同,只是参数名要加[],类型自己定义

例如:函数定义时的参数定义:

arg_lbm[] string value
pufan 2002-05-28
  • 打赏
  • 举报
回复
我是说把结构数组当作参数传进函数中来,我需要在函数中使用其中的数据。问题是我不知道如何进行参数设定啊。
pufan 2002-05-28
  • 打赏
  • 举报
回复
是不是这样:
在函数中
pass by :reference
argument type: s_temp//结构s_temp
argument name:s_1[]

s_1[1].label=""
可是这样系统老保错
海洋‘s 2002-05-28
  • 打赏
  • 举报
回复
将定义好的一个结构的某个参数直接在函数中调用即可。其实结构变量就等于一个全局变量一样啊。
参考一些以下代码:
1.定义一个结构变量:str_bitmap
Type Variable Name
long bmtype
long bmwidth
long bmheight
long bmwidthbytes
long bmplanes
long bmbitspixel
blob bmbits
2.定义用户对象:
 Instance Variables:
//代码:
boolean ib_mdi = false
 mdiclient i_mdi
 window iw_window
 string ls_bitmap
 ulong iul_hbitmap
 ulong iul_hmdi
 ulong iul_dcmdi
 ulong iul_hDCMem
 s_bitmap istr_Bitmap
 boolean ib_center = FALSE
 boolean ib_resize = TRUE
 integer ii_TitleBarHeight = 200

Local External Functions:
//代码:
FUNCTION int ReleaseDC(ulong handle, ulong hDC) LIBRARY "User32.dll"
 FUNCTION ulong SelectObject(ulong hDC, ulong hGDIObj) LIBRARY "Gdi32.dll"
 FUNCTION int BitBlt(ulong hDC, int num, int num, int num, int num, ulong hDC, int num, int num, ulong lParam) LIBRARY "Gdi32.dll"
 FUNCTION ulong CreateCompatibleDC(ulong hDC) LIBRARY "Gdi32.dll"
 FUNCTION ulong GetDC(ulong handle) LIBRARY "User32.dll"
 FUNCTION ulong LoadImageA( ulong hints, ref string lpszName, UINT uType, int cxDesired,int cyDesired,UINT fuLoad ) library "user32.dll"
 FUNCTION ulong GetObjectBitmap( ulong hgdiobj, int cbBuffer, ref s_bitmap bm ) library "gdi32.dll" alias for GetObjectA
 FUNCTION boolean DeleteObject ( ulong hgdiobj ) library "gdi32.dll"
 FUNCTION boolean StretchBlt(ulong hDCdest, int x1, int y1, int w1, int h1, ulong hDCsrc, int x2, int y2, int w2, int h2, ulong lParam) LIBRARY "Gdi32.dll"

3.在MDI窗体中编写代码:
 *定义一个用户自定义事件:ue_PostOpen()
Event Name:ue_PostOpen()
Return Type:None
//代码:
inv_wallpaper = create n_cst_wallpaper
 inv_wallpaper.of_SetWindow ( this, this.mdi_1 )

 inv_wallpaper.ib_Resize = false
 inv_wallpaper.ib_Center = true

 inv_wallpaper.of_SetBitmap ( 'Maps\Dataauditing.bmp' ) //图片路径和图片名
 inv_WallPaper.of_SetWallPaper(true)
 *定义第二个用户自定义事件:Ue_paint()
Event Name:ue_Paint()
Return Type:None
//代码:
if IsValid(inv_WallPaper) then
  inv_WallPaper.event post ue_Paint()
end if
*****W_Mdi的Open事件代码:
 This.event post ue_postopen()
*****W_Mdi的Resize事件代码:
This.event ue_Paint()
*****W_Mdi的Close事件代码:
destroy inv_WallPaper
**********************完毕*******************

***方法当然不止这一种,还有其他方法,听听其他同仁的意见吧.
[这是给Mdi窗体添加图片的代码,就用到了使用结构变量给函数传值]
yuanbo824 2002-05-28
  • 打赏
  • 举报
回复
和普通参数相同啊,有什么问题吗

1,108

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧