help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I pass a file pointer to my octfile?


From: John W. Eaton
Subject: Re: How do I pass a file pointer to my octfile?
Date: Sun, 26 Sep 2010 14:34:40 -0400

On 26-Sep-2010, baba wrote:

| Thanks! I got the file pointer using your second "tricky method" using the
| dynamic cast even though I do not really understand it I must say. But after
| returning to the calling script, I cannot continue writing to that file. 
| 
| So in my octave script I can call myOctFunction (FID, ...) and myOctFunction
| performs some writing to the file as expected. BUT when myOctFunction
| function returns, it turns out that I can no longer write to the file using
| fid. In other words in myOctaveScript.m I have something like this:
| 
| FID = fopen(myfile, 'w');
| myOctFunction( FID, ...); %this works as expected and writes data to the
| file
| 
| fprintf(FID, "some thing"); %does NOT write anything to the file
| ftell(fid) %returns -1 !!

It works for me.  If you want help debugging the problem you'll need
to provide a complete example that demonstrates the failure.

| I have tried closing, reopening the file and position the pointer to the
| end:
| fclose(FID);
| FID = fopen(myfile, 'w');

This truncates the file.  You need to use something like

  FID = fopen (myfile, 'a');

| Is there any way of still continue writing to the file from myOctaveScript
| once myOctFunction(FID, ..) returns?

As I said, it works for me.  So show us exactly what you are doing and
maybe someone can help you debug the problem.

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]