Wednesday, June 13, 2012

Cool trick which I never saw in LotusScript. Pass function as parameter.

Read this code
'Comments for SetValue
Sub SetValue(src As Variant, target As Variant)
 If IsObject(src) Then
  Set target = src
 Else
  target = src
 End If
End Sub

'Comments for Test
Function Test(value As Variant) As Variant
 SetValue value, Test
End Function
You can call Test(now) or Test(customobject) or Test("ABC") it will return you just same object/value. nice, isn't it?
msgbox Test(now).DateOnly
msgbox Test("Helllo")
msgbox Test(customobject).customProperty
Do not see right now really huge benefits from this but just nice to know this.

No comments: