Hi,
I want to create a file, which will serve as input file for some component.
For this, I have a template file, like this:
------------------------
Simulation time: 1000 ns
Molecule: XXXX
Method: Monte Carlo
Output: YYYY
Error: ZZZZ
etc...
------------------------
I assign the global variables XXX, YYYY and ZZZZ, but this is not clear to me how to pass them to this file so at the end I get a new file with the assigned values like:
------------------------
Simulation time: 1000 ns
Molecule: methane.inp
Method: Monte Carlo
Output: traj.dat
Error: error.txt
etc...
------------------------
For this purpose I looked to all the different components, but I do not find anything useful for my purposes.
Could you please tell me how would you proceed with this problem ?
Thanks
WS
I want to create a file, which will serve as input file for some component.
For this, I have a template file, like this:
------------------------
Simulation time: 1000 ns
Molecule: XXXX
Method: Monte Carlo
Output: YYYY
Error: ZZZZ
etc...
------------------------
I assign the global variables XXX, YYYY and ZZZZ, but this is not clear to me how to pass them to this file so at the end I get a new file with the assigned values like:
------------------------
Simulation time: 1000 ns
Molecule: methane.inp
Method: Monte Carlo
Output: traj.dat
Error: error.txt
etc...
------------------------
For this purpose I looked to all the different components, but I do not find anything useful for my purposes.
Could you please tell me how would you proceed with this problem ?
Thanks
WS

thanks a lot for the answer !
I tried your protocol and it works exactly the way I need it.
But afterwards, I tried to "insert" it into my bigger protocol and I get an error; mainly it complains about that "text" variable is not defined.
Am I doing something wrong ?
Thanks in advance
WS
I guess you have a text file with the information and you want to replace the XXX, YYYY and ZZZZ in the text.
I attached a protocol which can do it in 2 ways.
One more manually, where you read the input file by line and add the globalproperties with a if statement:
if Text = Molecule then Text := Molecule . @XXXX.
And so on for all your properties.
Or using a tamplate containing XXXX, YYYY, and you replace them by their globalproperties using a loop statement over the globalproperties on the whole text at once.
for #i in 1 .. numglobalproperties() loop
text:=strreplace(text,IthGlobalPropertyName(#i),IthGlobalproperty(#i));
end loop;
So the XXXX will be replaced by @XXXX.
I hope that what I wrote can be understood ( )
Jeremy
you're welcomed,
For the text property, it is because when I read the text file I put: no column name. So the information from the text is inserted in the property called "text".
For your big protocol you need to replace in the custom manipulator the property "text" by the name of the property which is holding your text/template.
Jeremy
Simulation time: 1000 ns
Molecule: $molecule
Method: Monte Carlo
Output: $output
Error: $error
it will first look for each variable in the data record properties, and if not found, in the globals.
You can use the "Output to Property" parameter to cause the template result to be output on a property which can then be fed into a text writer.
If you really need the input template to be in a file, you may be able to read it into a single property using a text reader, change the Template parameter on the HTML Template component to expression type, and set the template dynamically that way.