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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Error PRIME 10: This function accepts at most 18 arguments but is applied to 19

TNO-HTH
4-Participant

Error PRIME 10: This function accepts at most 18 arguments but is applied to 19

When running a Mathcad file in PRIME10 created in PRIME 9, I get an error:

“This function accepts at most 18 arguments but is applied to 19”

This restriction was not present in Mathcad 15 and earlier versions of PRIME.

 

TNOHTH_0-1718701240348.png

How to solve this?

 

added: 
Thanks for your reactions. The problem can be solved with future developments.

However, what about the existing MC sheets with locked areas with passwords where changes are not possible? This means these worksheets are unusable . Without an update from the author/owner of the sheet, this remains a serious problem. I would call it a bug, and Mathcad users should be warned about this problem before updating. In my opinion, the limit should be changed in a service pack P10.

23 REPLIES 23

Use subscripted variables:

 

Sums.png

 

Alan

Werner_E
25-Diamond I
(To:TNO-HTH)


@TNO-HTH wrote:

When running a Mathcad file in PRIME10 created in PRIME 9, I get an error:

“This function accepts at most 18 arguments but is applied to 19”

This restriction was not present in Mathcad 15 and earlier versions of PRIME.


I can confirm that you found yet another a new bug in Prime 10.

Functions defined for more than 18 arguments don't work!

Feel free to go through the hassle and report it to PTC support.

 

Werner_E_0-1718711937478.png

The attached file is in Prime 9 version where the bug does not yet occur, so if you open the sheet in Prime 10, you have to recalculate the sheet to see the difference and the error occurring.

 

A workaround, as Alan already suggested, is to use a vector with all 19 or more arguments as the only function argument.  If you need more meaningful variable names in you calculations (you would have to use indexed vector name) you could do it (a bit awkward) as shown here:

Werner_E_0-1718712616178.png

Additional benefit of this approach is that neither the function definition nor the function call take up much horizontal space and don't spill over the right page margin 😉

 

 

Cornel
19-Tanzanite
(To:Werner_E)

Yes, few moments ago I wanted to post also me this, but I was busy in meanwhile.
@DJNewman another bug was found in PRIME 10...

Cornel_0-1718713254461.png

 

Cornel_1-1718713267539.png

DJNewman
17-Peridot
(To:Cornel)

I agree that it's weird, especially because I can replicate that Prime 9 accepts many more arguments than Prime 10 does, but I disagree that it's a bug, given that this is documented in Help:

https://support.ptc.com/help/mathcad/r10.0/en/index.html#page/PTC_Mathcad_Help/about_built-in_functions.html#

 

"All PTC Mathcad functions, built-in or user-defined, are limited to accepting a maximum of 16 arguments."

 

(I guess you could say Help is wrong in that it seems to be 18 arguments and not 16, but I won't press the issue.)

 

The same quote is on the same page in Prime 9's Help:

https://support.ptc.com/help/mathcad/r9.0/en/index.html#page/PTC_Mathcad_Help/about_built-in_functions.html#


Edit: You have a few courses of action...
1. You can email feedback to the Mathcad Documentation team and say they should repeat the argument limitation number (and maybe use the correct number) on the page about defining user-defined functions by clicking the envelope in the corner

2. You can submit a Mathcad Idea asking the development team to increase the number of arguments for user-defined functions; though you'll have to give some kind of use case justification for why you need so many

I manage the Creo and PTC Mathcad YouTube channels for PTC, as well as all PTC Mathcad marketing in general.
Cornel
19-Tanzanite
(To:DJNewman)

For me its weird that such limitation exist! And even if this limitation had existed should be better at much higher number level of arguments.

StuartBruff
23-Emerald III
(To:Cornel)


@Cornel wrote:

For me its weird that such limitation exist! And even if this limitation had existed should be better at much higher number level of arguments.


User-defined functions with arbitrarily long (and arbitrary number of called) arguments are a long-standing Mathcad feature request, stretching back into the days of original Mathcad.

 

There are methods for handling such cases.   One possibility is via a folding function.  See ...

 

https://community.ptc.com/t5/Mathcad/Mathcad-Prime-fold-function/m-p/760552

 

Stuart

 

 

 

Werner_E
25-Diamond I
(To:DJNewman)


@DJNewman wrote:

... but I disagree that it's a bug, given that this is documented in Help:

https://support.ptc.com/help/mathcad/r10.0/en/index.html#page/PTC_Mathcad_Help/about_built-in_functions.html#

 


Well spotted, that hidden info! Thanks for pointing out..

So its not a  bug, but its sure not a feature, either.

 

While I would consider the use case for a function with that many arguments quite limited and as there sure are workarounds like splitting the calculation in more functions (if possible) or the already mentioned use of vectors as arguments, I still consider the limitation to 16 or 18 arguments to be a rather stupid limit. I wasn't aware that Prime introduced that limit here.
And yes, there is quite some room for documentation improvement!

 

Nonetheless I would call it a bug that Prime happily accepts the definition of functions containing more arguments..

An error with a clear error message should be thrown right when the function is defined - an error, not a warning, because at least in P10 a function defined that way can't be used in any way later.

LucMeekes
23-Emerald III
(To:DJNewman)

That same quote is in Prime's Help since after version 2 (Can't find it in Prime2's help; it's there in 3.1), but:

LucMeekes_1-1718746341003.png

I guess the development team found a bug (the limitation in the help is not adhered to by the software) and tried to correct it in Prime 10.

This has all the look and feel of PTC sofware.

 

Success!
Luc

StuartBruff
23-Emerald III
(To:DJNewman)

Additional Information
All PTC Mathcad functions, built-in or user-defined, are limited to accepting a maximum of 16 arguments.

 

OK, so the restriction applies to all PTC Mathcad functions, including built-in ones ...

 

About Array Characteristics Functions
max, min—Calculates the maximum and minimum values in an array.
 
And max is a (built-in) function (according to Help).
 
I'm going to regret pointing this out (as you said in an earlier message, a 'feature' might get 'fixed'), but ...
 
2024 10 09 A.png
 
There's a use case, as well: functions that are, from a UI perspective, best addressed by allowing for an arbitrary number of arguments.
 
Stuart

Do you want to gamble with Documentation? We could either get them to update the Help file with a correct number that isn't 16, or ignore it to hope they don't "fix" the product to restrict it to 16.

 

(I don't think it's a 50-50 outcome and that more likely than not, they would update the 16 number because it's easier to update the document than it is to update the product, and we love the path of least resistance. But I'm not 100% certain.)

 

I agree that allowing user-defined functions to allow an arbitrary amount of arguments instead of a predefined specific number of arguments has use cases. But that's a feature request outside the scope of this thread.

I manage the Creo and PTC Mathcad YouTube channels for PTC, as well as all PTC Mathcad marketing in general.
StuartBruff
23-Emerald III
(To:DJNewman)


@DJNewman wrote:

Do you want to gamble with Documentation? We could either get them to update the Help file with a correct number that isn't 16, or ignore it to hope they don't "fix" the product to restrict it to 16.

 

(I don't think it's a 50-50 outcome and that more likely than not, they would update the 16 number because it's easier to update the document than it is to update the product, and we love the path of least resistance. But I'm not 100% certain.)


 

I am not a betting man.  I can guarantee that my horse would come second in a one-horse race (or third in this case).

 


@DJNewman wrote:

I agree that allowing user-defined functions to allow an arbitrary amount of arguments instead of a predefined specific number of arguments has use cases. But that's a feature request outside the scope of this thread.


 

And talking of horses for courses, I think that arbitrary numbers of both formal arguments and given parameters go together like a horse and carriage.   But, as you say, that's a horse of a slightly different colour.

 

Here's some random thoughts that I put together back in 2007 when I was full of vim and vigour, prancing across the fields of life like My Little Pony instead of brooding wearily like an aged Horseman of the Apocalypse looking across fields of desolation and woe and wishing he'd bought a new saddle(*). 

 

I was primarily thinking about generalizing the concept of a sequence as it existed in Mathcad 15's for-loop, but that idea has almost certainly bolted the stable given the changes made in Prime.

 

Stuart

 

(Sigh.  Not only have I now got a string of equine-related puns circulating my skull, but I have the theme tune and lyrics of "Mr Ed" vying for attention as well)

 

(*) One of the earliest cartoons I recall seeing as a kid was a scene of a Dark Ages battlefield, bodies strewn everywhere, with one of the Four Horsemen looking at the other three with a look of utter disbelief on his face: "Stewards' Enquiry? What bloody Stewards' Enquiry?".  There's no accounting for what a 7-yr old thinks is funny, I suppose.

 

I don't think I've ever pranced in my life, and that trapped nerve in my back says I won't be doing any today, either.

Hello @TNO-HTH

 

It looks like you have some responses from some community members. If any of these replies helped you solve your question please mark the appropriate reply as the Accepted Solution. 

Of course, if you have more to share on your issue, please let the Community know so other community members can continue to help you.

Thanks,

Vivek N.
Community Moderation Team.

LucMeekes
23-Emerald III
(To:vnamboodheri)

I guess the problem of the OP is not solved. It could be solved if:

PTC corrects the documentation to become in line with the implementation, and I strongly recommend an error message on the function definition, where the number of arguments is above the limit.

Better still would be to remove the limitation from the implementation ( keep it as it was before Prime 10) and from the documentation.

 

Success!

Luc

DJNewman
17-Peridot
(To:TNO-HTH)

This has been fixed in Mathcad Prime 10.0.1.0.

This screenshot is of Werner's example with the function defined with 19 arguments. Note that in 10.0.0.0, using it with 17 arguments failed (as it should), the 18 arguments passed (as it shouldn't), and the 19 arguments failed (as it shouldn't).

In 10.0.1.0, 17 arguments fail, 18 arguments fail, and 19 arguments passed, which is expected behaviour.

DJNewman_0-1728479380017.png



(And if you give it 20 arguments it fails again, as it should.)

I manage the Creo and PTC Mathcad YouTube channels for PTC, as well as all PTC Mathcad marketing in general.
Cornel
19-Tanzanite
(To:DJNewman)

Message deleted by author

DJNewman
17-Peridot
(To:Cornel)

I'm not sure I understand...?


Because the user-created function in the example takes 19 arguments.
If the user wanted some other "X" amount of arguments, then replace 19 with that amount.

It wouldn't make sense for the user-created function to take less than "X" or more than "X".

No one thinks that 10.0.0.0 failing at this was a good thing, so 10.0.1.0 fixed it.
If you're asking why 10.0.0.0 happened to break at this amount of arguments, I have no idea, but obviously it wasn't intended behaviour.

I manage the Creo and PTC Mathcad YouTube channels for PTC, as well as all PTC Mathcad marketing in general.
Cornel
19-Tanzanite
(To:DJNewman)

Yes, ok, I understand. But do you know if in 10.0.1.0 is possible to create a function with more than 19 arguments, like this for example:

Below is in 10.0.0.0:

Cornel_0-1728487198438.png

Cornel_1-1728487222236.png

 

Try in 10.0.1.0 this.

 

DJNewman
17-Peridot
(To:Cornel)

DJNewman_0-1728487873236.png

Like this?

I manage the Creo and PTC Mathcad YouTube channels for PTC, as well as all PTC Mathcad marketing in general.
Cornel
19-Tanzanite
(To:DJNewman)

Yes, like this. It's ok then.

Werner_E
25-Diamond I
(To:DJNewman)


@DJNewman wrote:

If the user wanted some other "X" amount of arguments, then replace 19 with that amount.

It wouldn't make sense for the user-created function to take less than "X"

I'm afraid I have to disagree.

It would make much sense and would be a benefit to have if we could have optional arguments in user-defined function as we have with some built-in functions.

This would mean that a function defined with X arguments can be called with less than X arguments and the function can deal with the missing arguments, maybe replacing them by defaults or branching to a different calculation routine.

As an example a  function areaOfElipse(a,b) could default to b=a (circle) if the second argument is omitted.

A function f(a,x):=a*sin(x) could return a function(!) if the second argument is omiited.

While Mathcad did not support optional arguments in user-defined function, too, it allowed at least to call a function with less than the maximal number of arguments, so the latter example could be realized and this was very useful and convenient!

Werner_E_0-1728490359981.png

 

DJNewman
17-Peridot
(To:Werner_E)

I would agree if Mathcad Prime currently had that functionality, but as user-defined functions are currently implemented where all arguments are mandatory, Mathcad should give an error message if there is a mismatch.

 

In the future (which has to be requested for) if Mathcad Prime let people make user-defined functions and a user could define arguments to be optional, then that's another story!

I manage the Creo and PTC Mathcad YouTube channels for PTC, as well as all PTC Mathcad marketing in general.
Werner_E
25-Diamond I
(To:DJNewman)


@DJNewman wrote:

I would agree if Mathcad Prime currently had that functionality, but as user-defined functions are currently implemented where all arguments are mandatory, Mathcad should give an error message if there is a mismatch.

Fully agreed on.

My reply was triggered by your "It wouldn't make sense for the user-created function to take less than "X" " because I feel it would make much sense but of course Prime would have to undergo heavy improvement to be able do so.

DJNewman
17-Peridot
(To:Werner_E)

I'm just speaking in the context of the original problem that was fixed in the new maintenance release and nothing more.

I manage the Creo and PTC Mathcad YouTube channels for PTC, as well as all PTC Mathcad marketing in general.
Announcements

Top Tags