LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  getting error when trying to access the graph parameter from filter node

    Employee
    Posted 08-21-2014 04:43

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: rakhi

    I have declare a graph parameter "SourcePath" and assign value " SourePath = D:\Lavastorm\Workspace\Iinput\". But when i am trying to access it from filter node getting error "Unexpected Token ( at line 2".
    In filter node I have written the following code

    path = {{^SourcePath^}}

    Please suggest how I could do this.

    Thanks in advanced.


  • 2.  RE: getting error when trying to access the graph parameter from filter node

    Employee
    Posted 08-21-2014 05:03

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Tim Meagher

    Hey,

    Using the {{^^}} textual substitution mechanism for parameters substitutes the text directly into where it is referenced - without doing any other operations (no quoting, no esaping, just direct textual substitution).

    Therefore if you have:
    SourePath = D:\Lavastorm\Workspace\Iinput\


    And you use:

    path = {{^SourcePath^}} 


    This produces invalid brainscript:

    path = D:\Lavastorm\Workspace\Iinput\
    What you want is probably to have this quoted and escaped (as the '\' character denotes an escape sequence):

    path = "D:\\Lavastorm\\Workspace\\Iinput\\"
    Or:

    path = "D:/Lavastorm/Workspace/Iinput/"
    In order to do this, you can either set your SourcePath parameter to something like:
    SourePath = "D:\\Lavastorm\\Workspace\\Iinput\\"


    or change the '\' characters to '/' characters in the SourcePath and change your path reference to:

    path = "{{^SourcePath^}}"


    There is another alternative which is to assign a runtime property name to the SourcePath parameter.
    However, the runtime property would need to be defined on the node itself.
    To do this, in the node editor, you would declare a parameter "SourcePath" via the "Declare Parameters" dialog.
    Then, set the Runtime Property Name to some value (e.g. node.sourcePath or something).
    Then within your script you are able to reference this using:

    path = property("node.sourcePath")
    When using the property accessor, this is evaluating a property and you are able to assign it to a variable.
    Using this mechanism, since it isn't directly inserting text into the script you don't need to worry about escaping or quoting.

    Regards,
    Tim.


  • 3.  RE: getting error when trying to access the graph parameter from filter node

    Employee
    Posted 08-21-2014 05:05

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: ejones

    Whatever you have in the SourcePath parameter is used to replace the string {{^SourcePath^}} in the BRAINscript code. The result is that:
    path = {{^SourcePath^}}
    becomes
    path = D:\Lavastorm\Workspace\Iinput\
    But instead I believe you wanted:
    path = "D:\Lavastorm\Workspace\Iinput\"
    so your BRAINscript code should instead contain quotes and should be:
    path = "{{^SourcePath^}}"

    But additionally, it is an unfortunate thing that the back slash (\) character has different meanings in different contexts. Inside a string in BRAINscript it is an escape sequence meaning that the backslash combined with the next character should be a certain value. And the \L character sequence causes an error since that combination doesn't mean anything. There are two options that come to mind to fix this.
    1. LAE (and many other languages) allows you to substitute the forward slash (/) for the back slash in many locations. So you can probably change the parameter value to instead be D:/Lavastorm/Workspace/Input/
    2. The escape sequence for the back slash character involves making the second character a back slash character. So in that case you can change the parameter to be D:\\Lavastorm\\Workspace\\Input\\