Skip to main content
1-Visitor
May 6, 2020
Solved

Problem with a while loop

  • May 6, 2020
  • 3 replies
  • 8659 views

Hi everyone,

 

I´m programming a plate heat exchanger, the flow begin in single-phase and when certain conditions are met, it change to twin-phase.

 

I write a while loop, it works and everything is correct.

 

The first problem comes when I try to introduce some more line and assign a new variable name to it, it fails, I have to reuse a variable name already used inside the loop, it is not solved by declaring the variable outside the program, neither in the program but outside the loop or inside the loop. The failure it gives is the following "" Ldtoken, Ldftn and Ldvirtftn OpCodes cannot have DynamicMethod as their destination ".

 

The second problem appears in the result array, certain variables fail when appearing together in the result array, only if there are two or more of them, one at a time they do not fail. I have observed that the variables that fail are those found from line 17 in the loop, the previous ones do not fail, and it does not matter if I previously declared them outside the program, inside the program but outside the loop or inside the loop. The only solution is to put just one of those variables.

 

I use MC14

 

It's weird, right?

 

Thanks for your help.

 

Greetings, Jesús

Best answer by jesusmor

Hi everybody,

 

One guy give me a operative 15th version, I have installed and both sheets run whitout problem.

 

Which is the reason? Who knows, MC mania.

 

Thanks a lot for your time, I´m glad to meet you and it won´t be the last time I´ll come here.

 

Kind regards!!

 

jesusmor_0-1588958389108.png

 

3 replies

23-Emerald IV
May 6, 2020

Please attach your worksheet.

Without it, there's little we can do.

 

Success!
Luc

jesusmor1-VisitorAuthor
1-Visitor
May 6, 2020

You´re reason, sorry!!

 

I send the attachment

jesusmor1-VisitorAuthor
1-Visitor
May 7, 2020

Hi Luc,

 

I send both worsheets.

 

Thanks for your time.

25-Diamond I
May 8, 2020

I, too, can confirm that both sheets run without any errors.
Mathcad 15, M050

Can you post a pic with the error message you get in the "fail" sheet and where the error traces back to (right click on the error and chose trace)

jesusmor1-VisitorAuthor
1-Visitor
May 8, 2020

Thanks everybody!!

 

You guys found the trouble, good job!!.


But, the next question is: Why does MC14 fail?, doesn't it has solution?, should I change for the MC15?.

 

I don´t know if this change is possible, it is a work for an university.

 

Let´s going!!

23-Emerald IV
May 8, 2020

I don't see an immediate need to upgrade to Mathcad 15, as 14 and 15 are equally buggy with respect to this from my point of view.

 

But you should make sure that L.sp is given a value before the start of that large while loop.

If that solves your problem, then you can mark this thread as answered.

 

Success!
luc