El 14/07/11 08:52, Pietro Battiston escribió:
Hello,
I'm trying to have a rapid way to output numbers to files, and wrote the
following:
# A function to dump numbers to files:
function scalar to_file(scalar numb, string format, string filename)
set echo off
set messages off
outfile filename --write
printf format, numb
outfile --close
set echo on
set messages on
return 0
end function
which however doesn't work. By trying different specifications, I think
I have understood that the "filename" parameter of "outfile" and the
"format" parameter of "printf" cannot be variables, they are parsed
directly as strings by the interpreter.
Did I understand correctly?
Is there anything I can do to solve my problem?
I do not care too much, in the end, about "format", but if there is no
way to pass an arbitraray string to "outfile" I'm clearly trying
something stupid.
Thanks in advance
Pietro
I think that only adding "@" to the filename of the 'outfile' command
as in:
outfile @filename --write
your function should work. (not tested)
--
Ignacio Diaz-Emparanza
DEPARTAMENTO DE ECONOMÍA APLICADA III (ECONOMETRÍA Y ESTADÍSTICA)
UPV/EHU Avda. Lehendakari Aguirre, 83 | 48015 BILBAO
T.: +34 946013732 | F.: +34 946013754
www.ea3.ehu.es