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.  Printing parameter value in a field

    Employee
    Posted 02-14-2013 06:46

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

    Originally posted by: aop

    Hi!

    I have a parameter called Directory and the value of it can be e.g. "C:\Users\xyz\Documents\A\2012\data\test". Is there any way I could use emit expression to include the value of the parameter as a field in the data? Emit "{{^Directory^}}" as FIELD does not work due to challenging value of the parameter (invalid escape sequence in string). My idea would then be to use this parameter as a property available to a BRX.


  • 2.  RE: Printing parameter value in a field

    Employee
    Posted 02-14-2013 07:13

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

    Originally posted by: stonysmith

    Flip the delimiters:
    C:/Users/xyz/Documents/A/2012/data/test
    most versions of windows will accept the folder names this way.

    or double them:
    C:\\Users\\xyz\\Documents\\A\\2012\\data\\test


  • 3.  RE: Printing parameter value in a field

    Employee
    Posted 02-14-2013 07:15

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

    Originally posted by: Tim Meagher

    Hey,

    As far as I am aware this isn't possible.
    The {{^^}} syntax is used to directly substitute the value of a parameter into the contents of another parameter (in this case a BRAINscript parameter).
    When this textual substitution is done, then the substituted text must conform to the syntax of the BRAINscript parameter.

    One option would be to add additional escapes into your filename, e.g specify c:\\Users\\xyz\\Documents\\...

    If you really need to output the value of a parameter and adding extra escapes isn't an option, you could do this in a Python or Java node.
    When you are using the Python and Java nodes, you can then use the properties object which will evaluate the parameters value, and return this as a String - meaning that you do not need to use the direct textual substitution mechanism.
    However, on the node where you are evaluting the parameter, it needs to have a Runtime Property Name set in its parameter declaration.
    This means that if you define the File parameter on a composite node, or on a graph level parameter, and within that composite or graph you want to output it's value on an output pin (and you can't use BRAINscript due to the escape characters), then you will need to redeclare this parameter on the Python or Java node, and set it's runtime property name.

    As an example, I've attached a graph which shows how this can be done using the Python & Java nodes, just outputting the File parameter, which is defined with a Runtime Property Name of "ls.brain.node.file".
    If you want to have this in something like a filter, whereby you are just appending the filename to all of the input records, then you can easily do this with a Python Filter node, an example of which is also shown in the attached graph.

    Hope this helps,
    Tim.
    Attachments:
    parametersExample.brg


  • 4.  RE: Printing parameter value in a field

    Employee
    Posted 02-14-2013 08:30

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

    Originally posted by: aop

    Doubling/flipping delimiters seems like a very easy solution although it has a slight downside from usability perspective as user needs to replace those manually each time.

    I was also thinking of one quick&dirty approach that would be possible in my scenario as I'm using the same Directory parameter in a directory list node in combination with a delimited file input node to load data in the same project. I could probably add a FileNameOutputField in one of the delimited inputs and take the field value from there using head node with record count 1, parse the filename out from the end and then join the directory value to the data where I need need it for the BRX.

    However, maybe I'll use the sophisticated python/java examples as such were provided. Thanks for help!


  • 5.  RE: Printing parameter value in a field

    Employee
    Posted 02-25-2013 09:11

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

    Originally posted by: rboccuzzi

    Hey, another method that I think will held you is flagging the string as containing escape sequences, so treat it as "raw" or "regex", via prefixing with the letter r.

    So this:
    emit "c:\User\Test" as "SomeField"

    will error
    but this:
    emit r"c:\User\Test" as "SomeField"

    will work, because of the 'r' prefix to the string.

    So I think you could do something like:

    emit r"{{^Directory^}}" as "DirectoryParameter"

    Cheers
    Rich