eval
The API eval sends an expression to the server to be evaluated either synchronously, asynchronously, or at a scheduled time.
Parameters
- cmd
- Required. A text string containing the expression to evaluate. Separate multiple expressions with a semicolon (;). If the user does not supply this parameter, the server returns an appropriate error message.
- async
- True if the function is to be run asynchronously; otherwise false . By default, 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.
Remarks
Each call 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.
When you run a job synchronously, because it runs immediately, it is not put into the job queue; therefore, it does not appear in the list returned by jobs.
The jobId is a property of the SPXML results string and appears as follows:
<SplusDataResult hasReturnValue="true" hasTextOutput="true" hasError="false" hasWarnings="false" created="Mon Sep 24 14:33:12 PDT 2012" jobId="25" status="2" engineTime ="27" serverTime ="37" queuedTime ="4" serverInstance ="myserver">
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.
If you schedule a request, and you specify an invalid time (for example, in the past), the request is run synchronously, on the first available engine.Example
The following link sends the expression "6*7" to the server to evaluate at the schedule time. (Note that an expression to be evaluated by the Expression Service is sent as a string, not an SPXML-encoded object.)
http://servername:8080/SplusServer/api/v8/expression/eval?cmd=6*7&at=1348522205088To use a special character (such as "+") in your Expression Service eval URL, you must use special encoding. For a list of these characters, see Special Characters.
The following link sends the function sort as an expression, passing in the arguments for sorting on the Disp. column of the fuel.frame data set.
http://servername:8080/SplusServer/api/v8/expression/eval?cmd=sort(x=Sdatasets::fuel.frame$Disp.,na.last=T)
The following link sends the function sort as an expression, passing in the arguments for sorting the supplied numbers.
http://servername:8080/SplusServer/api/v8/expression/eval?cmd=sort(x=c(2,4,1,3,5),na.last=T)