Warning: Trying to access array offset on value of type null in /home/site/wwwroot/lib/plugins/move/action/rename.php on line 42

Warning: Cannot modify header information - headers already sent by (output started at /home/site/wwwroot/lib/plugins/move/action/rename.php:42) in /home/site/wwwroot/inc/common.php on line 1955

Warning: Cannot modify header information - headers already sent by (output started at /home/site/wwwroot/lib/plugins/move/action/rename.php:42) in /home/site/wwwroot/inc/actions.php on line 38
concatenate_strings_in_input_file [topas wiki]

User Tools

Site Tools


concatenate_strings_in_input_file

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
concatenate_strings_in_input_file [2010/10/01 15:30] – created johnsoevansconcatenate_strings_in_input_file [2022/11/03 15:08] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +====== Joining strings in an input file ======
  
 +You can concatanate strings in a text file to build up complex filenames etc using the following:
 +
 +<code topas>macro data_directory {c:\data\storage_directory\}
 +macro file_stem {dataname_}
 +macro run_number {0000}
 +macro suffix {.xy}
 +
 +macro file_dets(data_directory, file_stem, run_number, suffix) 
 +{
 +               data_directory##file_stem##run_number##suffix
 +}
 +macro file
 +{
 +               file_dets(data_directory, file_stem, run_number, suffix) 
 +
 +
 +file</code>
 +
 +which will expand to:
 +
 +<code topas>c:\data\storage_directory\dataname_0000.xy
 +</code>
 +The ## concatenation sequence is a c pre-processor construct and only concatenates macro arguments hence the double step.
 +
 +
 +Similarly you can e.g. change the name of an output .xy file with macros like:
 +
 +<code topas>macro lor { 1000 }
 +
 +macro File_Out_(n)
 +{
 + voigt##n##.xy
 +}
 +
 +Out_X_Ycalc(File_Out_(lor))</code>