Nick, a solution to the Imperative code block issue can be found in this discussion on the forum.
It is possible to reference variables, however, those references need to be brought in as input parameters in the function being defined.
In your example, for the function to return linepreview, it first needs to have linepreview brought in as an input parameter
def active(linepreview)
{
return=linepreview;
};
Important: This example serves no real purpose and does not in any way demonstrate the purpose or utility of functions. The utility of the example is limited to the issue raised here.