Passing Objects

本文详细介绍了如何在PeopleCode中使用对象作为函数参数,包括如何传递复杂的数据结构,如属性引用和行集。通过示例展示了如何在函数中直接操作实际对象而非其副本,以及如何遍历和更新传递的行集记录。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

All PeopleCode objects can be passed as function parameters. You can pass complex data structures between PeopleCode functions (as opposed to passing long lists of fields). If a function is passed an object, the function works on the actual object, not on a copy of the object.

In the following simple example, a reference to the Visible property is passed, not the value of Visible. This enables the MyPeopleCodeFunction either to get or set the value of the Visible property:

MyPeopleCodeFunction(&MyField.Visible);

In the following example, the function Process_Rowset loops through every row and record in the rowset it is passed and executes an Update statement on each record in the rowset. This function can be called from any PeopleCode program and can process any rowset that is passed to it.

Local Rowset &RS; Local Record &REC; Function Process_RowSet(&ROWSET as Rowset); For &I = 1 To &ROWSET.Rowcount For &J = 1 To &ROWSET.Recordcount &REC = &ROWSET.GetRow(&I).GetRecord(&J); &REC.Update(); End-For; End-For; End-Function; &RS = GetLevel0(); Process_RowSet(&RS);

The following function takes a rowset and a record passed in from another program. GetRecord does not take a variable for the record; however, you can use the @ symbol to dereference the record name.

Function Get_My_Row(&PASSED_ROWSET, &PASSED_RECORD) For &ROWSET_ROW = 1 To &PASSED_ROWSET.RowCount &UNDERLYINGREC = "RECORD." | &PASSED_ROWSET.DBRecordName; &ROW_RECORD = &PASSED_ROWSET.GetRow(&ROWSET_ROW).GetRecord(@&UNDERLYINGREC); /* Do other processing */ End-For; End-Function;

转载于:https://www.cnblogs.com/GoDevil/archive/2009/01/19/1378136.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值