The problem is that there is no clean standard way to return multiple values. This thread is proposing a way of defining a standard method to achieve it. It's not about enforcing a method but rather producing quidelines for a standard way of doing it if you want to, the "KiXtart Result Array Passing" HOWTO if you like. Perhaps someone can think up an acronym for it?
The purpose of ordering the values in a particular way is so that it makes sense for the error value to be in the same place every time.
I don't believe that the process adds significant complexity. Here is a trivial example:
code:
Function udfSquare($iNumber)
Dim $Result[4]
;
$Result[0]=0 ; Success
$Result[1]="Operation completed successfully"
;
$Result[3]=$iNumber * $iNumber
$Result[2]=1 ; One data value returned
;
$udfSquare=$Result
Exit $Result[0] ; Set ERROR on exit
EndFunction
;
;
$avResult=udfSquare(1024)
If @ERROR
udfErrorHandler($avResult)
Else
"Result: " $avResult[3]
EndIf
There is very little extra code in the function, and no extra code in the calling script.
You can immediatley see another benefit. If an error occurs I hand off the processing to a generic error handler routine. This can display the error number and message, and can even display the returned value(s) for debugging. This error handling will work for every function which is coded with an array returned in the suggested format.
[ 16 April 2002, 10:31: Message edited by: Richard Howarth ]