Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: Tim MeagherHi,
I've attached a node that provides a template to allow for easy configuration of instances of this node to perform simple BRAINscript operations over an input field list.
The node itself won't run, rather, the idea is that if you wanted to create a set of nodes that perform such simple operations, this would be a good place to start.
There are example instances in the attached graph for converting a set of strings to upper case, to proper, and calculating the sum and average for each of a set of input fields.
Essentially, all you need to do to create an instance of this node for a specific purpose is to define whether the node should perform an always aggregation step (e.g. "To Upper" and "To Proper" shouldn't, but "sum" and "average" - if someone using the node doesn't specify the fields to group on, should group on all fields).
Then, you need to provide some BRAINscript in the "CustomFunction" parameter.
The "CustomFunction" parameter is a BRAINscript parameter than will be textually substituted into (and therefor evaluated) the main script for each of the specified fields and for each input record.
The "CustomFunction" parameter is substituted into the main BRAINscript in a context such that the value of the input field being processed is available in the "inputFieldValue" variable, and the script in the "CustomFunction" parameter needs to set the calculated value for that field in the "calculatedValue" variable.
For instance in the "To Upper" example, the script is simply:
calculatedValue = inputFieldValue.toUpper()
In any case, there are existing nodes in the Lavastorm Analytic Library or on the forums already which will perform the operations given in the examples in a much more efficient manner and at least in LAL, these are obviously fully supported.
I'm not entirely sure of the general use of this node, but I put it together based on a request, so I thought I'd share it here.
Maybe someone else will find it useful, or think of a way to improve it and post their own version here
Regards,
Tim.
Attachments:
PerformOperation.brg