B4R Question can we create a sub with parameters who are subs like callsubplus ?

candide

Active Member
Licensed User
with callsubplus we can do:
B4X:
CallSubPlus("DoSomething", 1000, 5)
'...

Sub DoSomething(Tag as Byte)
'......
End Sub

can we do the same with a sub i create "mysub" ?
B4X:
MySub("DoSomething",  5)
'...

Sub DoSomething(Tag as Byte)
'......
End Sub
 

candide

Active Member
Licensed User
yes šŸ˜
but if a part of code is in a library it is not possible...
if i have a library, at init i have to provide several subnames to this library .. and library will run subs when needed.

it is possible from C++ library with callback from wrapper, but in this case definition of callback is done in C++ in wrapper.

just i wanted to know if it is possible to do that in B4R, in case of library written in B4R

in CallSubPlus definition we have:
CallSubPlus (SubName As SubVoidByte, DelayMs As ULong, Tag As Byte)

i tested subvoidbyte type, but it is unknown type...
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The code from the b4xlib is added to the project as-is. Everything you can do in "regular" code module can be done with a b4xlib library, and the opposite is also true.

You should do the same thing I did in rHttpUtils, simply call the sub that you want. The developer using your library will get an error until they add it.
 
Upvote 0
Top