Passing/returning scalar v arrays

i have a subroutine that looks things up from the nab. the returned variable could either be a scalar value or an array. so my question is if i pass an argument to a sub with an dynamic array reference:

subName (rtrnVal())

is there anything i have to do in the main prog to account for a different return type?

thanks

Subject: re: passing/returning scalar v arrays

if I get you right you’re trying to pass an argument into a subroutine ByReference, change its value within the routine and then grab the changed value once you’re back in the calling routine (if I didn’t get you right then please forget the rest of this…)

I’d change two things:

  1. use a function instead of a sub: functions are truly designed to return values

  2. functions can’t return arrays, but they can return variants, and variants can be anything (including arrays)

So I’d do something like

function fncSomething(args) as variant

the calling routine would then query the function’s return value for its type, e.g. using something like

if isarray(fncSomething) then

Hope this helps

Subject: never used functions

been programming in notes since R1. another developer friend of mine recommended functions too.

i guess i gotta go figure them out now.

Subject: functions…

yep, think you should :slight_smile:

it’s easy: they’re the same as subs only that they can return something. The return value is assigned inside the function in that way:

functionName = returnValue

The function’s return type must match the data type of the return value. If the function returns an object you must use “Set functionName = …”

That’s all there is.

Good luck

Subject: notesdocument.getitemvalue always returns an array

notesdocument.getitemvalue always returns an array.

Dim total As Integer

Dim money As Variant

total = 0

money = notesdocument.getitemvalue( “quarterlyRevenue” )

Forall m In money

total = total + m

End Forall