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

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

calling one worksheet from within a loop in another

MichaelSchwende
1-Visitor

calling one worksheet from within a loop in another

Hello,

I am new to this software (and these forums) and have run into a problem that I don't know if mathcad can handle (I'm running Mathcad 14). I have a rather large application that looks up data values in tables, makes calculations, and produces an output, all based on a "section number" that is specified at the top of the program. It works great for individual section numbers, but now I am looking to have the program cycle through ALL the possible numbers. However, I'd rather not have my program become one massive "for" loop, nor would I like to add an indexed subscript to every single variable or make every variable instead a function of section number. This program is trying to be user-friendly and easily modified, so I'd prefer to leave the individual program as is, and "call" it from another worksheet, which itself is doing the looping over all numbers. Is there any way to accomplish this? I've tried having a "reference" to the original sheet in another sheet, which seems to work, but these references cannot be placed in loops. I'm open to other suggestions to accomplish this task, which really doesn't seem like it should be impossible but I have yet to find a way. Any ideas?

3 REPLIES 3

What you want to do is possible, but not completely trivial. You can create a function based on a scripted component that calls one worksheet frm another, and then put that function in a loop. There's an old thread on this topic here:

https://communities.ptc.com/message/84798#84798

Unfortunately, when everything was migrated to these new forums it was decided to delete all worksheets more than 5 years old, so all the worksheets in that thread are gone. Fortunately, the old forum is still up and running for now (but mostly locked to read only), so here's the thread with the worksheets:

http://collab.mathsoft.com/read?58873,19e#58873

You can try to loop all of one worksheet using the variable FRAME for animations. At the end of the worksheet can use SAVEPRN with cat and num2str to save on hard disk those values that you want to preserve, one for each FRAME value, and then animate just this SAVEPRN instruction.

Regards. Alvaro.

Richard, I'm sorry to say that the worksheets you suggested don't seem to work on my computer as is (they mention that you need Mathcad 11, I wonder if this is the problem, I encounter many "null pointer" exceptions or something like that), but more importantly I don't understand what it is they are attempting to do. Any chance you could make up an overly simple example demonstrating the technique you are discussing? I'm thinking just one worksheet looping through x=1:5 and calling another worksheet that adds a number to x and returns the value to some variable y (when it comes down to it, this is for basically all I want anyway). The solution using FRAME and animations works (thanks Alvaro!) but isn't the most elegant solution I guess. Beggers can't be choosers so unless Richard you can better describe your solution i'll have to stick with that one.

Announcements

Top Tags