function
Sends a function and its parameters to the server to run synchronously, asynchronously, or at a scheduled time.
Parameters
- function
- Required. The function to run. If the user does not supply this parameter, the server returns an appropriate error message. Follow with a question mark (?) and the arguments. (See the Example for more information.)
- package
- The name of the library or package that contains function.
- arg
- The function's arguments, separated by an ampersand (&). (See the Example for more information.)
- async
- A logical value. true if the function is to be run asynchronously; otherwise false.
- at
- The time, in milliseconds, since epoch to schedule the job at a future date.
Return value
If run asynchronously, the resulting SPXML string contains only the jobId and job status; if run synchronously, the resulting SPXML string contains the results of the evaluation. See Remarks for more information.
Remarks
http://servername:8080/SplusServer/api/v8/function/libraryname/functionname
Each evaluation is known as a "job." Jobs can be run synchronously or asychronously. A synchronous job retains control of the browser and waits for the returned SPXML; an asychronous job sends the request to the server and returns control to the browser, allowing you to continue working, and allowing the job to run at a later time.
The jobId is a property of the SPXML results string and appears as follows:
<SplusDataResult hasReturnValue="true" hasTextOutput="true" hasError="false" hasWarnings="false" created="Weds Mar 6 12:40:36 PDT 2019" jobId="111" status="2">
When you send an asynchronous evaluation request, the SPXML results return immediately, but they contain only the jobId and job status. You can capture and use the jobId to find your results in the results directory at a later time.
Example
http://servername:8080/SplusServer/api/v8/function/rnorm?n=5&mean=30