Can the byRef type be used as params in soft declare subroutines/functions?

Can byRef be used when calling into an external dylib / DLL, for intrinsic types like Integer? For example:

soft declare sub someSubroutine lib dylibLocation (clsPtr as Ptr, byRef N as Integer)

dim N as Integer = 10 someSubroutine(N)

If someSubroutine() is defined as:

void someSubroutine(int& theInt) { theInt += 10; }

Will the value of N after the call to someSubroutine(N) equal 10, or 20?

Yes, you can pass any parameter to a declare as ByRef. In your example N will be 20 after the call.

Holy Smokes – that’s fantastic! Because it’s nice to provide a error return value that can be “by Reference”.

I get frustrated with Python (or is it JAVA?), where only complex data structures (lists, dictionaries) are passed by reference (actually, ALWAYS by reference), but if I want to receive back an error in an integer, I either have to return it as the value of the function, or return a tuple, or a structure containing multiple items.