Filename based on parameter: How can we add a parameter in a filename so that the filename changes, based on the parameter?

Use the normal &V[varname] notation in the filename, e.g.:

Set V[filename] "C:\temp\&V[plantparam]\barcode.txt"

OpenFile "&V[filename]"

AppendFile ...

CloseFile "&V[filename]"

By the way, instead of C:\temp you can also use the Windows TEMP-variable; notation is &%[xxx] where xxx is the name of the environment variable:

Set V[filename] "&%[TEMP]\&V[plantparam]\barcode.txt"