This is an example about how to replace LenA with a different implementation. I provide this as follow-up to my answer to Miguel in https://community.appeon.com/index.php/qna/q-a/lena-function-problem-after-migrating-to-powerbuilder-2022#reply-44332.
global type lena from function_object
end type
forward prototypes
global function long lena (string as_str)
global function long lena (blob abl_blb)
end prototypes
global function long lena (string as_str);messagebox("1", "This is a custom implementation of lena")
return len(as_str)
end function
global function long lena (blob abl_blb);messagebox("2", "This is a custom implementation of lena")
return len(abl_blb)
end function
The main problem with that implementation is that from IDE you can only add one signature for a global function! The second one was added using Edit Source.
Example for calling:
messagebox("Resulting Length:", lena("testing"))
messagebox("Resulting Length:", lena(blob("testing")))
In my tests both calls will first show the messagebox inside lena and after the "Resulting Length" messagebox.
While it's possible to change that way a PB's system function with our own implementation, this should be carefully used... That's because, if someone reads the code in a later time, it may not be aware of that change... It can be confusing. Also, in that specific case we have to be sure that we won't have to work with DBCS strings.
Andreas.