cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Is it possible to delete a file in a folder from within Mathcad ?

PatriceBujard-d
1-Visitor

Is it possible to delete a file in a folder from within Mathcad ?

Dear all,

1) I have an application which generates large files. Once I read these files from within mathcad I don't need them anymore and I would like to delete them.

Presently I do it by hand from windows explorer. Is it possible to delete a file in a specific folder from within Mathcad ?

2) When mathcad is open and runs since some times (couple hours) I observe that it is running slower and slower, like a memory saturation effect (in truth I don't know). Usually I quit mathcad and start it again. Then it runs again normally.

Can someone tell me if I can "refresf" mathcad from mathcad, without having to close it and start again ?

Thank you

ACCEPTED SOLUTION

Accepted Solutions
RichardJ
19-Tanzanite
(To:RichardJ)

Here's a new version. There was a bug in the one I just posted.

View solution in original post

19 REPLIES 19

You could see if the attached worksheet can help.

You can change the default path to your desired location. Once the file has been found you can just press delete on the keyboard. I'm sure the script can be coded to you can automatically delete the file, but I'm not very good at scripting, so I have attached in M11 format so hopefully one of other members can help.

Mike

Patrice,

On your second question: There have been some recent threads on this, but a partial summary is this:

Mathcad does not clean up the memory as you work, with the exception that variables and matrices created inside a program

are deconstructed, or memory cleared up, when you exit the program.

Otherwise you must do as you have indicated.

Some other things that help, depending on what your are doing:

You could close other programs that compete for memeory.

Re-use matrices that are no longer needed, thereby using blocks of memory that are already allocated.

Sometimes you can perform calculations in one file and then reference into the current file, those calculations are static,
(i.e., do not recalculate, unless you select the referenced file and select recalculate). I do this for long job files: When a
file stats to slow down, I open a new file and reference in the last one, sometimes up to 4 files deep.

Make routines more efficient by pre-allocating matrices, doing more operations inside programs, do operations using column vectors as
much as possible, try to stay away from the vectorize operator and program instead.

Hope this helps, and maybe some others will comment and help me too.

Wayne

Patrice Bujard wrote:

Is it possible to delete a file in a specific folder from within Mathcad ?

If you are doing it by hand then you can do it directly from within MathCad - no need to use Windows Explorer.. Just choose File/Open, choose All File Types, select the file of interest (or, disinterest, I guess!), right-click and choose delete from the context menu.

Alan

Yes it is (at least for a text file),

I have posted my collected Utilities file at http://communities.ptc.com/docs/DOC-1612

I will be adding a V11 version as well.

The create and delete utilities still contain the MsgBox dialogs so that you can see what is happening.

One of the utility scripts will give an error if the area is closed when the sheet is open.

Philip

Finally, noting Alan's comments, readers should also get hold of the PathCopy4 utility (freeware) that is ideal for getting full path names for use in emails etc. Use Alan's trick to find out, via path copy, your own path via a trial 'save as'. (wonderful in corporate environments where server paths can be many and varied)

Here's a function based on a scripted component that will delete a file.

Note that the file is permanently deleted! It will NOT appear in the recyle bin!

It is more flexible and has better error handling than the one in Philips document.

In addition to the utilities pointed to by Philip, there are a lot of other scripted components in the document I posted here:

Extra Components.mcd

That's definately a lot better than my proof of concept component!

My Create() function could also be improved!

I'll update my Utilities with the ones you offered.

Philip

RichardJ
19-Tanzanite
(To:RichardJ)

Here's a new version. There was a bug in the one I just posted.

Nicely done Richard.

Is that an update to your Extra Components worksheet?

Mike

Yes, I added the new delete file function to the Extra Components worksheet.

You should create a blog with that worksheet in, superb collection.

Mike

OK, but only if you can tell me how to fit 25 hours in each day

wayne
12-Amethyst
(To:RichardJ)

Richard,

It's been said that Chuck Norris has counted to infinity...twice.

He only has 24hr in a day.

Wayne

Don't start the Chuck jokes........

Mike

RichardJ
19-Tanzanite
(To:wayne)

He only has 24hr in a day.

Yes, but he has an infinite number of minutes in an hour, and an infinite number of seconds in a minute. That's why he can not only count to infinity (twice), but can also kick the crap out of 30 guys in less time than it takes for you to blink.

OK, but only if you can tell me how to fit 25 hours in each day

I have faith in you.

http://communities.ptc.com/servlet/JiveServlet/showImage/38-1286-11146/thumbsup.gif

Mike

Youki
1-Visitor
(To:RichardJ)

Thank you Richard,

I would like to give you the labe "answered" but I cannot find the spot where to click it !!

I started to work with Mathcad since Mathcad 1 (it was DOS) but I didn't go in deep details like you guys.

RichardJ
19-Tanzanite
(To:Youki)

I would like to give you the labe "answered" but I cannot find the spot where to click it !

Don't worry about it. I'm not going to

Edit: I see you just found it anyway
big_grin.gif

Richard,

The "Extra Components" lead to an error message and Mathcad exits. What happens ? (I have Mathcad 14.0.0.163 (build 701291152) and no administration rights.

Thanks

You need to download and install the service release. That's M020 if you are a single user, M030 if you are an Enterprise user (do NOT install M035, which has a very bad bug).

Announcements

Top Tags