We all know how useful local variables are since they provide a way to avoid "contamination" of the pipeline with spurious temporary/working variables in PilotScript. But, as the help says: "If an expression makes a change to a local property when processing a data record, that change remains until the next data record is processed within that component." But more precisely, if an expression changes the local variable, then the change remains until the local variable is assigned again. For example, the following protocol:
when the Customer Manipulator contains:
if Index = 2 then
#flag := true;
end if;
if #flag is defined then
flag := #flag;
flag_is_defined := true;
end if;
The output is:
Index | flag | flag_is_defined |
1 | ||
2 | true | true |
3 | true | true |
As you can see #flag is assigned on the 2nd record, but it remains assigned on the 3rd. But what if we want the local variable to be destroyed on each invocation of the Custom Manipulator? I haven't found a "supported" way of removing a local variable, Remove(''#flag') doesn't do anything.
A workaround is to use: ChangePropertyType(#flag, 'Scitegic.Value.NullValue');
So this code:
ChangePropertyType(#flag, 'Scitegic.Value.NullValue');
if Index = 2 then
#flag := true;
end if;
if #flag is defined then
flag := #flag;
flag_is_defined := true;
end if;
Will result in this output:
Index | flag | flag_is_defined |
1 | ||
2 | true | true |
3 |
Now #flag is no more defined for the 3rd record. But I think it would be better to have Remove('#flag') work or may be a more explicit function, like RemoveLocalProperty(property), for example.