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

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

Use own functions in multiple documents

Googol
1-Newbie

Use own functions in multiple documents

Hello,

is there a possiblity to export own Mathcad 14 functions which are commonly used in multiple documents without beeing urged to redefine them the very same way for each document? I know the possibility to build a Mathcad dll library, but that is not the solution I am searching for.

Thank you!

Googol

16 REPLIES 16
StuartBruff
23-Emerald II
(To:Googol)

One method, if you're prepared to think in advance, is to use References. Create a worksheet with your definitions in, use the Insert/Reference menu command to insert it into your main worksheet; this will make all of your functions available. If you make changes to the Reference worksheet (ie new or amended functions) these will reflect into all of the worksheets that reference it. Add it to your normal template and you will get it automatically included in new worksheets.

However, if you have a stable set of functions, then you can just include the functions directly into the normal template (or have a suite of templates that have specific sets of functions) and these, again, will be made available to any new worksheet. The downside is that you'll have to manually modify each worksheet if you want to change a 'library' function, but, OTOH, you wont have to worry about path changes if you change the library folder path (eg, send somebody else the main worksheet ... you'll need to include the reference worksheet and the other party will probably have to edit the sheet to remove the old reference and point to their new local reference location.

Stuart

A new feature in Mathcad Prime is caching included worksheets. If you choose caching, the definitions from the included worksheet will be cached in the parent worksheet, and you won't have to worry about editing the path.

Mona

StuartBruff
23-Emerald II
(To:mzeftel)

Mona Zeftel wrote:

A new feature in Mathcad Prime is caching included worksheets. If you choose caching, the definitions from the included worksheet will be cached in the parent worksheet, and you won't have to worry about editing the path.

Mona

Sounds good, Mona. Is there any user control over what will be cached or automated checks that, say, only used functions / variables are cached? Is the caching recursive (ie, worksheets referenced by reference worksheets)?

Stuart

The caching can be turned on or off. The default is to have it on. My understanding is that caching includes all definitions that could be useful in a parent worksheet. It does not include images, text, plots, etc, that are not needed. The caching is recursive.

Mona

wayne
3-Visitor
(To:mzeftel)

Mona,
You confused me, could you unconfuse me?
When you open a file with a file referenced, it opens the reference file and cashes, every time you open (or choose update)?


If so, then don't you still need to update the file reference path if the original location changes; for this point, it does not matter wether cached or not?

Another question, that will really show my ignorance, but is the cached memory the same as the working memory that Prime uses, so after cached, it's the same as if it was in the calling file, from a memory standpoint?

If this is the same memory, then I don't understand the difference, unless caching excludes the plots,etc. and not caching does not exclude.

If the work sheet is a porject that is developed on the fly, then how would it determine what definitions are useful?

For example, Is there any advantage to importing large date sets into a file reference and caching, as opposed to directly importing into the worksheet?

Thanks

RichardJ
19-Tanzanite
(To:wayne)

I don't guarantee this is right, but I tihnk it is

When you save the file anything that affects calculation in an included sheet is cached in the saved file. So all assignments are cached, but evaluations, graphs, etc are not.

When you open a file Prime first looks for any included worksheets. If it can't find them, it uses the cached information. So a worksheet should always work, even if the included file is missing for some reason.

wayne
3-Visitor
(To:RichardJ)

Richard,
Thanks for your response.
Probably don't need the details, just know that it works. But if I open a file, and then use functions in a reference sheet that were not previously used, then Prime would have to go back and search referenced files to see if there, since it would not have been cached.

Not trying to be difficult, just trying to see what the advantage to caching is, so I might take advantage.

For the large matrix, would you expect any difference in cached or imported directly into worksheet?

At this point, the only advantage I can see is that the file might load faster, but then is the same.

RichardJ
19-Tanzanite
(To:wayne)

Probably don't need the details, just know that it works. But if I open a file, and then use functions in a reference sheet that were not previously used, then Prime would have to go back and search referenced files to see if there, since it would not have been cached.

Yes, that is true. As far as that goes, there is of course no advantage over MC15.

Not trying to be difficult, just trying to see what the advantage to caching is, so I might take advantage.

In MC15, if you lose connection to the referenced worksheet, for example because the directory structure was changed, the parent worksheet no longer works. I have even made the mistake in the past of deleting a worksheet, or changing it's name, because I forgot it was referenced. This has in fact burned me enough times that now I never, reference a worksheet! In Prime, the parent worksheet will always continue to work, even if the referenced worksheet is no longer available. For some people this might be an issue, because of traceability to current standards, etc, but that's why the caching option can be turned off.

For the large matrix, would you expect any difference in cached or imported directly into worksheet?

I doubt there would be much difference. The referenced worksheet will slow anything down a little, because it has to be opened in addition to the parent worksheet, but I wouldn't expect much overhead beyond that.

wayne
3-Visitor
(To:RichardJ)

Thanks Richard.

Our work is different, I always reference files into the job template, not doing so would not be pratical for me, but then I am a designer and use the same funcitons over and over, job after job after job after job after job. Now I am depressed.

I don't know the exact details in terms of order, but as Richard is correct, that the advantage of caching, is that you can send one worksheet to a another person, or move the main worksheet, without worrying that all the included (referenced) worksheets are sent as well and that they stay in the same directory structure.

Mathcad 15 allows you to set relative paths, but as Richard wrote, if you rename or move a worksheet that was referenced, suddenly the main worksheet won't work.

I don't know for sure, if there's a speed advantage or caching versus including worksheets, but I don't think so.

Mona

wayne
3-Visitor
(To:mzeftel)

Mona, Thanks

I think I got it now and I see the advantages. For me, I need to know what version of the referenced file is being used, so I think I will trun caching off.

Wayne

RichardJ
19-Tanzanite
(To:wayne)

For me, I need to know what version of the referenced file is being used, so I think I will trun caching off.

Can't you just put the version information in the referenced worksheet, and then display it in the top level worksheet? Then you would always know what version is being used, even if it's cached (it may not be the version you want, but you will know what it is!)

wayne
3-Visitor
(To:RichardJ)

I am not using Prime for design yet. And I may change my mind when I do.

But say I add a feature (fix a bug) in a referenced file. I assume I could update the cached references easily enough, but would I have to remember to do that, and would I remember if I did already or not. I can track major revisions or Codes easily enough, but tracking every lilttle feature change is too much overhead for me.

Lets say I have referenced files that themselves include reference files (which I do have), and I add a "feature" to the lowest file and update the reference in the job file, will that feature be updated in that file, or will it be missed because the intermediate file reference used the cached version? Will I remember If I cashed it or not?

This will be pretty easy to test (I don't have to test my memory, it's completely unreliable), but until I know exactly what's going on, it could be vary dangerous for me.

RichardJ
19-Tanzanite
(To:wayne)

I haven't tested it, but my understanding is that if the referenced file is available, at any level of referencing, then the information in the file is used. The cached information is used only if a particular file is not available. I don't know hat happens when you have, say, file1 referencing file2 wich in turn references file3 and file4, and file4 is missing. I assume it uses the cached information only for file4, but I don't now that for sure.

I'll check on the exact details of how it works. I know that if an included worksheet is updated, the change isn't reflected in the main worksheet, until it recalculates. So I'm assuming that the caching all the way through is updated too.

Mona

Thank you Stuart,

this is exactly what I'm looking for!

Googol

Top Tags