Returning Multiple Results to the Client
You can package multiple results (arrays and scalars) and return them to the client where they can be unpacked and used.
To package multiple results on the server, create and return an associative array of data name/value pairs. For example, the following JWAVE wrapper function returns multiple results to the client:
FUNCTION PASSFFT, client_data
; Get the data from the client.
arr = GETPARAM(client_data, 'ARRAY', /Value)
;Process the data, creating two separate variable results
freq = FLOAT(ABS(FFT(arr, -1)))
distrib = HISTOGRAM(freq)
; Create associative array to send results back to the client.
RETURN, ASARR('FDATA', freq, 'HIST', distrib)
END
The resulting arrays, freq and distrib are packaged and returned to the client in the associative array. The associative array keys become the names of the returned data referenced by the client with the getReturnData method. The names of the data returned by this example are FDATA and HIST.
The following example shows a Java code fragment used to retrieve the parameters sent from the server and to properly cast the values.
Client calls to unpack associative array sent from the server.
//Get the FFT data
float[] d = (float[]) command.getReturnData(”FDATA”);
//Get the histogram data
int[] h = (int[]) command.getReturnData(”HIST”);
Version 3.6
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.