datahub_commanddatahub_command — sends commands to the DataHub program.
datahub_command (command, sync?)
commandA string containing a DataHub configuration command.
sync1 sends the command synchronously;
0 sends the command asynchronously.
The result of the command, as a string.
This function sends configuration commands to a DataHub instance, in Lisp format. It returns the result of the command as a string. For more information on DataHub commands, please refer to the Using DataHub Commands chapter of the Cogent DataHub manual.
Setting the sync parameter to 1
(synchronous) may slow the execution a tiny bit, but it ensures that the DataHub
instance will complete the command before your script continues. Setting the
sync parameter to 0 will allow
your script to continue whether or not the DataHub command has executed. For most
cases, we recommend setting it to 1, just to be on the safe
side. This ensures that your script will execute commands in the order expected.
The tiny delay for synchronous execution is in
micro-milliseconds—insignificant for most applications.
Since commands are sent within strings, you probably need to escape certain
characters, using the backslash (\). For example, to escape
the quote marks delineating the string "my_string", you would
enter the string as: \"my_string\".
Normally if a command is in a configuration file, you need to escape the backslash in file names, like this:
c:\\tmp\\datahub.log
But, if you are issuing the command from gamma using datahub_command you need to escape each of those two backslashes, like this:
c:\\\\tmp\\\\datahub.log
So the command would be:
datahub_command ("(log_file \"c:\\\\tmp\\\\datahub.log\")")Since the quotes are optional (though recommended) in DataHub commands you could do this:
datahub_command ("(log_file c:\\\\tmp\\\\datahub.log)")Fortunately, recent Microsoft operating systems will accept forward slashes in file names, so for those versions you can do this:
datahub_command ("(log_file c:/tmp/datahub.log)")This example creates a new point in the DataHub instance, and sets its value to
5.
if (undefined_p($default:MyNewPoint))
{
datahub_command ("(cset default:MyNewPoint 5)", 1);
}