Variadic function

Questions about MultiCharts and user contributed studies.
hoishing
Posts: 4
Joined: 31 Aug 2020
Been thanked: 1 time

Variadic function

Postby hoishing » 04 Sep 2020

Hi,

How can I create a varidic function which accept variable number of inputs? (just like the built-in print function does)

I searched in the wiki but no luck... thanks

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Variadic function

Postby TJ » 04 Sep 2020

I am not too sure what you mean by "Print Function".

What EXACTLY do you want to do?

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Variadic function

Postby JoshM » 04 Sep 2020

As far as I know it's not possible in MultiCharts PowerLanguage to make a function that accepts an arbitrary number of argument values.

What you can do as a workaround is to give the function an array input, and then inside the function loop through the array and collect the argument values that way.

hoishing
Posts: 4
Joined: 31 Aug 2020
Been thanked: 1 time

Re: Variadic function

Postby hoishing » 05 Sep 2020

@TJ, I want to create function with arbitrary number of arguments, is it possible in PowerLanguage?

If not, maybe I can work-around with array as @JoshM suggests.

thanks for the reply :)

User avatar
Tammy MultiCharts
Posts: 200
Joined: 06 Aug 2020
Has thanked: 6 times
Been thanked: 65 times

Re: Variadic function

Postby Tammy MultiCharts » 06 Oct 2020

@TJ, I want to create function with arbitrary number of arguments, is it possible in PowerLanguage?

If not, maybe I can work-around with array as @JoshM suggests.

thanks for the reply :)
Hello hoishing,

Please use the solution suggested by JoshM: accessing the argument values through an array input.


Return to “MultiCharts”