Results 1 to 4 of 4

Thread: How to avoid parameter <> is not defined error

  1. #1

    Question How to avoid parameter <> is not defined error

    I try to develop a library node based on core::python. In this node I need to simulate the input behaviour of the core::Delimited File node:
    1. By default, it does not have an input pin. The input file name is provided by a parameter named File, which is declared in this node as string type, none validator.
    2. When drag the output pin of another node and drop into this node, it will create an input pin and the node will read input from self.inputs.

    The node worked fine in scenario 1. However in scenario 2 where the parameter File was not used, it didnt have a value. Executing the node would trigger an error Parameter <File> is not defined. The error was triggered by a line of code inFile = "{{^File^}}" in Python2Implementation.

    I added ls.brain.node.tailFile.CreateTail.InputPath to the File parameters Run Time Property Name, and replaced the code with
    inFile = self.properties.getString("ls.brain.node.tailFile. CreateTail.InputPath", None)
    but received the same error.

    It looks like when a parameter is declared, it must a value. That doesnt suit my purpose. Is there any way to avoid this?

  2. #2
    Lavastorm Employee
    Join Date
    Aug 2009
    Location
    Cologne
    Posts
    513

    Default

    Hey,

    First, using the {{^File^}} implementation means that the property substituter will go through and attempt to substitute in the property prior to analyzing any of the python code. This is true for any case when you use the {{^^}} notation.
    You can always set defaults to use in case the property isn't set, for example {{^File=NotDefined^}} or something similar. In this case, rather than the node failing straight away, if the File parameter is not defined, then the default of NotDefined is used.

    Using the run time properties means within the python code means that the property is only attempted to be obtained if that line of code is ever executed.

    You can try a similar thing by providing a default value (other than None) such that this won't throw an error if the property isn't defined - e.g. in your case, this could be something like:

    Code:
    inFile = self.properties.getString("ls.brain.node.tailFile. CreateTail.InputPath", "NotDefined")
    However, this isn't really the best way.
    Since the property isn't searched for unless the code reading it is executed, the best way to handle this is simply to make sure that this code isn't executed if you have an input pin.

    This can be done using the following logic:

    Code:
    if len(self.inputs) == 0:
    	#Should attempt to read file parameter here
    else:
    	#Attempt to read the stuff from input pin
    Without knowing exactly what the use case is, this seems like it should fit with what you want to do.
    I've attached a graph with a working example, which just spits out text onto the output pin, dependant on whether or not an input pin was present.
    Attached Files Attached Files

  3. #3

    Smile

    Hi Tim,

    Thank you very much for the prompt response. Actually I came very close to the solution you have suggested, except in the self.properties.getString function, I had none instead of "NotDefined". The python code works now after the replacement.

    It took me long time, a lot of guesswork, as well as asking around, to work on this part of BRAIN. Your assistance is valuable and highly appreciated. However is that any documentation available in addition to the core.brg help library?

  4. #4
    Contributor
    Join Date
    Dec 2006
    Location
    Boston
    Posts
    485

    Default

    Aside from the help on the core library, there is help on BRE and BRAINscript...some of the BRE help deals with parameters. To access that help, inside of BRE, click on the Help menu, and then choose BRE Help.

    When IE comes up, take a look at the contents on the left, and check out the Parameters section. Additionally, you can find more help in the online Training Guide, that gets installed with our product. Inside the start group, look under documentation.

    Cheers
    Rich

Similar Threads

  1. Java Node Runtime Parameter Access
    By phourigan in forum Nodes
    Replies: 3
    Last Post: 03-01-2011, 01:11 PM
  2. Set value of parameter using BrainScript
    By mgajdosik in forum Nodes
    Replies: 2
    Last Post: 06-07-2010, 02:12 PM
  3. Replies: 4
    Last Post: 03-22-2010, 06:06 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •