[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Passing parameters with a file
Thank you, Carl.
This is just what I needed to get my program working.
Jim
=============================================================
--- In femm@xxxx, "Carl Kopin" <ckopin@xxxx> wrote:
> Hi Jim,
>
> Try this:
>
> In the preprocessor create your file like this:
>
> handle=openfile('mydata.txt','w')
> write(handle,'my comment 1\n', 'my comment
> 2\n',data1,'\n',data2[,'\n',data3[,...]])
> closefile(handle)
>
>
> In the postprocessor read your file as follows:
>
> handle=openfile('mydata.txt','r')
> line1,line2,d1,d2=read(handle,'*l','*n','*n')
> close(handle)
>
> Writing the mydata.txt file is simple, the trick is to properly
read it.
> If you ad a comment line or to in the beginning of your file, you
have
> to read it it/them first before your data, that's why you add '*l'
( the
> "l" is a lower case L, which means to read whole line) in the
beginning
> one for each line, and then you add the '*n' (to read numbers) as
many
> times as needed to read your data. You don't need to read the whole
> file, but you must read it from the very beginning to the last
point of
> your interest. You do not need your comment lines in your
postprocessor,
> but you must read them to a "junk" var in order to access the data
part.
> To send/read characters, in the preprocessor use the form of 'my
> char\n', in the postprocessor use '*w' that stands for word. You
can use
> "new line" (\n) or tab (\t) as your delimiters. (Are spaces OK,
too? I
> am not sure, did not try.)
>
> I think, this will help you (and possibly others, too).
> Other comments are welcomed.
> Carl
>
> -----Original Message-----
> From: jim271@xxxx [mailto:jim271@xxxx]
> Sent: Sunday, August 19, 2001 08:23
> To: femm@xxxx
> Subject: [femm] Re: Lua sample of line integral
>
> Dave,
>
> Thank you for the example. This is very helpful.
>
>
> Dave: " As far as getting information from one iteration to the
next,
> or from the preprocessor to the postprocessor, perhaps the easiest
> way to do this is via the use of a temporary file. I have used a
> temporary file in this example to send the current plunger position
> to the postprocessor so that it can write this piece of info to the
> output file. "
>
> I can get the post processing file to read one variable that is
> passed by the main script file, but I can't seem to get it to read
> two or more data values from the same line of the data file.
>
> Can someone please show an example of reading multiple variables
from
> a file by the post processor?
>
> -- Jim
>
>
>
>
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/