Discussion:
Writing to files
Martyn Amos
2005-08-10 11:45:30 UTC
Permalink
Folks,

I have got the CLI version of Breve working under XP and Cygwin. I am trying
to capture the output of the simulation to a file, so that I can automate the
(many) test runs that I need to carry out. However, the output of a straight
print doesn't seem to be captured if I redirect the output to a file. So, I
have tried to dump the locations and sizes of various objects to a file (see
below). However, when Breve gets to this routine it complains about not being
able to convert vectors to strings.

I would very much appreciate your advice on what (if anything) I'm doing wrong
here.

Many thanks in advance,

Martyn

# This is a menu item that prints the locations of objects to stdout
+ to export-locations:
thing (object).
it (object).

it = new File.
it open-for-writing with-file ("output.txt").


foreach thing in (all Items):
{
if (thing get-owner) != 1:
{
it write-line text ((thing get-location)).
it write-line text ((thing get-size)).
}
}

it close.

---
Dr Martyn Amos
Lecturer in Computer Science
School of Engineering, Computer Science and Mathematics
University of Exeter, United Kingdom
Email: M.R.Amos*at*exeter.ac.uk
WWW: http://www.dcs.ex.ac.uk/~mramos
jon klein
2005-08-10 14:00:33 UTC
Permalink
Post by Martyn Amos
Folks,
I have got the CLI version of Breve working under XP and Cygwin. I am trying
to capture the output of the simulation to a file, so that I can automate the
(many) test runs that I need to carry out. However, the output of a straight
print doesn't seem to be captured if I redirect the output to a file. So, I
have tried to dump the locations and sizes of various objects to a file (see
below). However, when Breve gets to this routine it complains about not being
able to convert vectors to strings.
it write-line text ((thing get-location)).
In version 2.2, breve does not automatically do the conversion to
strings, as
you note. This has already been fixed for version 2.3, but in the
meantime,
the workaround is to simply embed a vector variable in a string for
formatting,
as in the example below:

location (vector).

location = (thing get-location).

it write-line text "$location".

- jon klein

Loading...