Skip to content
  • There are no suggestions because the search field is empty.

How do I create a DataHub script with a Point name that has a space character?

I have a quick question:

I want to see the value of a point but the tag name as a space in it.  When typing the name in the script log, it displays an error message:
--> $Test2:SimulatePLC.INPUTS.Int Ramp
Script error during command: $Test2:SimulatePLC.INPUTS.Int Ramp:
  Error: String: line 1: Malformed expression
 
What can I do to overcome this problem?
A symbol (variable name) in Gamma can contain any character.  There are two ways to do what you want:
  1. Write the symbol as:  $Test2:SimulatePLC.INPUTS.Int\ Ramp. The backslash is used to escape the following character.  You can write:
    $Test2:SimulatePLC.INPUTS.Int\ Ramp = 123;

     

  2. Create the symbol indirectly, as in:
    x = symbol ("Test2:SimulatePLC.INPUTS.Int Ramp");

    This would create the symbol and assign the symbol into x.  Now you have an indirect reference to the symbol that you can use in other functions, such as OnChange calls.  You can assign a value to an indirectly referenced symbol using the set() function, as in:
    x = symbol ("Test2:SimulatePLC.INPUTS.Int Ramp");

    set (x, 123);    // $Test2:SimulatePLC.INPUTS.Int\ Ramp is now 123
    You can get the value of an indirect symbol by evaluating it, as in:
    y = eval (x);    // y is now 123