Hi,
it is important to understand the difference between a user parameter and a variable.
A user parameter (published or private) can only be set before the workbench starts. Once the workbench runs, these values cannot be modified. They are the input to your process.
A variable is a temporary setting that only exists during the execution of the workspace. You use the VariableSetter and VariableRetriever inside the workspace to get and modify the values of the named variables. Variables are particularly useful when looping through features, e.g. so that one feature can access an attribute value of a preceeding feature.
David
Hi David,
Thanks for the explanation regarding the difference and uses of variables and parameters, it is a great help.
Out of interest if I isolate the value and commit the value using VaraibleSetter, then use a tester to separate can use the Variable Fetcher ACTUALLY within the tester transformer?
i.e. in psuedo BASIC
Let A=(isolated line_number value)
then test remaining records
If line_number > A then send one way, else send another way
Thanks again,
Rob
Hi,
you cannot reference a variable inside the Tester itself. You must first use the VariableRetriever to read the variable into an attribute, which you then use in the Tester.
See the doc for more info.
David
Hi David,
Ok thanks very much, that is a pain.
Your work around was essentailly what I had originally done but not using a Variable opion. I isolated the value then used feature merger to join the isolated value back to all the remaining records as a new attribute field, and then tested each record to see it the line-number was less than the added attribute. It worked fine but I felt that a clearer method may exist.
It is a shame that FME does not allow you to treat the variable as a runtime 'parameter' where you can dervive the value during execution and the allow you to perforrm tests agaianst the value.
Thanks again for your help and advice.
Regards,
Rob
Hi Rob,
If you will assign the line number of the specific feature to a variable via the VariableSetter, be aware the variable value does not exist before arriving of that feature. I think that using of the FeatureHolder before the VairableRetriever is a frequently used way. Since the FeatureHolder will hold all input features until the last one arrives, the variable will be set certainly before the VariableRetriever.
But the VairableRetriever seems to fetch an empty string when the specified variable doesn't exist, so maybe you can determine whether a feature came before the specific feature by testing if the fetched value is empty or not. Another an (interesting) approach.
That is, using "Mutliple Feature Attribute Support" and "Conditional Value Mapping" functionalities of the AttributeCreator.
These two AttributeCreators create an attribute named _flag; the value of _flag will be 0 if input feature came before the specific feature (i.e. its attribute value = the specific text), otherwise will be 1. Then, the feature flow can be branched into two ways via the Tester.
The second AttributeCreater setting is tricky a little.
For your information.
Takashi