Eval Function
Executes a Command window statement from a program and returns the error status.
Syntax
Eval( command [, reply$ ] )
Parameters
- command
- Specify the command to be executed as a string.
- reply$
- Optional. A string variable that contains the reply from the command. If the command is in the error status, it will return “!Error: error code”. If the reply is over 255 characters, the extra characters will be truncated.
Return Values
The error code returned from executing the command.
Even if the command execution results in an error, the function itself will not be an error. Also, the system log doesn’t record it.
When the command is completed successfully, it returns “0”.
Description
You can execute any command (executable commands from Command window)
from communication port such as TCP/IP by using Eval.
It takes more time to execute this function than by using a normal statement.
Use the reply$ parameter to retrieve the reply from the command. For example, if the command was “Print Sw(1)”, then reply$ would be a “1” or “0”.
See Also
Error Codes
Eval Function Example
This example shows how to execute a command being read over RS-232. After the command is executed, the error code is returned to the host. For example, the host could send a command like "motor on".
Integer errCode
String cmd$
OpenCom #1
Do
Line Input #1, cmd$
errCode = Eval(cmd$)
Print #1, errCode
Loop