Posted 2 April 2020, 3:21 am ESTI suspect I don't use VBScript enough to identify why this isn't working. I'm getting numerous errors in trying to write a custom function in Report.GlobalScripts
It's not a particularly complex function, but here's
Function FormatTime(ByRef totalSeconds)
Dim hours = totalSeconds / 3600
Dim minutes = (totalSeconds mod 3600) / 60
Dim seconds = totalSeconds mod 60
FormatTime = hours + ":" + minutes + ":" + seconds
This gives me an error that variables are being used before they're initialized. Breaking assignment away from declaration seems to work. I say seems to, because the error changes.
Now I get "object reference not set to an instance of an object" - but there's no further information and I can't debug to see what's not set, where. So, if I don't call the function it doesn't happen, and if I do I get that error even dumbing it down to just this:
FormatTime = totalSeconds
Is this not VBScript? Or VBA? I'm at a total loss for what could possibly be wrong here, at this point. I work in C# normally and every reference I look at for VBScript says this syntax is the correct way to return a value from a function.