continuously running a program

  • Follow


Hi,

I want to be able to run a script continuously until i decide to terminate it. Right now, i have doing so but for reasons i am not sure of yet, the program terminates randomly. I want to somehow make it return to processing if such a thing occurs. I thought i could make my script into one big function, and at the very end i call that function again so it will re-run the program if it was to terminate. However, in my program, i am continuously reading from an external device and writing to test files. If i was to call the program again at the end, it would overwrite those test files. 

How can i have it restart without overwriting the text files it started with? how can i just have it open those files and continue writing from where it left off?
0
Reply Bilal 11/8/2010 5:07:05 PM

"Bilal " <bilalhaider87@gmail.com> wrote in message <ib9anp$qts$1@fred.mathworks.com>...
> Hi,
> 
> I want to be able to run a script continuously until i decide to terminate it. Right now, i have doing so but for reasons i am not sure of yet, the program terminates randomly. I want to somehow make it return to processing if such a thing occurs. I thought i could make my script into one big function, and at the very end i call that function again so it will re-run the program if it was to terminate. However, in my program, i am continuously reading from an external device and writing to test files. If i was to call the program again at the end, it would overwrite those test files. 
> 
> How can i have it restart without overwriting the text files it started with? how can i just have it open those files and continue writing from where it left off?

One way:

doc persistent

use persistent variables for your file name's index numbers.
0
Reply Sean 11/8/2010 5:17:04 PM


Dear Bilal,

>Right now, i have doing so but for reasons i am not sure of yet, the program terminates randomly.

It is unlikely, that a program terminates randomly. It is most likely a good idea to find the underlying bug.

Jan
0
Reply Jan 11/8/2010 5:34:03 PM

On 10-11-08 11:07 AM, Bilal wrote:

> I want to be able to run a script continuously until i decide to
> terminate it. Right now, i have doing so but for reasons i am not sure
> of yet, the program terminates randomly. I want to somehow make it
> return to processing if such a thing occurs. I thought i could make my
> script into one big function, and at the very end i call that function
> again so it will re-run the program if it was to terminate. However, in
> my program, i am continuously reading from an external device and
> writing to test files. If i was to call the program again at the end, it
> would overwrite those test files.
> How can i have it restart without overwriting the text files it started
> with? how can i just have it open those files and continue writing from
> where it left off?

The first step in this process would be to add a try / catch pair in order to 
detect the termination and permit the restart.

The second step would be to open the text output files with 'at' permission 
instead of with 'wt' permission: 'wt' permission clears the current contents 
of the text file, but 'at' permission appends the data to the end of the text 
file (creating it if it does not exist.)
0
Reply Walter 11/8/2010 6:59:17 PM

"Jan Simon" <matlab.THIS_YEAR@nMINUSsimon.de> wrote in message <ib9cab$9kh$1@fred.mathworks.com>...
> Dear Bilal,
> 
> >Right now, i have doing so but for reasons i am not sure of yet, the program terminates randomly.
> 
> It is unlikely, that a program terminates randomly. It is most likely a good idea to find the underlying bug.
> 
> Jan

I understand what you're trying to say. i chose that work incorrectly. It's just i have to leave the program running for a few days at a time and it will terminate over night, and since i have it running as an executable, i don't quite know where it terminates. I'm still working on that part.
0
Reply Bilal 11/8/2010 8:44:04 PM

4 Replies
427 Views

(page loaded in 0.035 seconds)

Similiar Articles:













7/25/2012 1:38:46 AM


Reply: