Putting text from a loop in a variable

mkress
mkress New Altair Community Member
edited October 2020 in Community Q&A

Hi guys,

my script reads a document and afterwards manipulates every line of it. step by step, every line is written into an outfile.

 

'while {[gets $data lines] >=0} {

 

…..

 

set outfile [open $path/report.txt a+]

 

...

 

if {![regexp {N/A} $field2]}      {

 

….

 

puts $outfile '[format $formatStr $a $b $field1 [format '%.1f' $dif_temp]]'

 

 

 

}

close $outfile

 

}'

 

 

 

Now I want to put every lines in a variable, that I don´t need the outfile. But with “set” I have only the last line of the loop in the variable.

 

set var '[format $formatStr $a $b $field1 [format '%.1f' $dif_temp]]'

 

 

 

 Could anyone help me there?

Answers