Control of input parameters in prgms./fns.
12-27-2013, 02:26 AM
Post: #1
 John P Member Posts: 191 Joined: Dec 2013
Control of input parameters in prgms./fns.
Is there any way, inside a program/function in HP Prime, to tell haw many input parameters were passed and modify the prgm./fn. behavior accordingly. As far as I know if you declared 3 parameters and enter while running the prgm./fn. two or one you will get error.
Thanks.
12-27-2013, 02:31 AM
Post: #2
 eried Senior Member Posts: 712 Joined: Dec 2013
RE: Control of input parameters in prgms./fns.
No way, there is no http://en.wikipedia.org/wiki/Polymorphis...r_science)

My website: erwin.ried.cl
12-27-2013, 04:34 AM
Post: #3
 Han Senior Member Posts: 1,804 Joined: Dec 2013
RE: Control of input parameters in prgms./fns.
(12-27-2013 02:26 AM)John P Wrote:  Is there any way, inside a program/function in HP Prime, to tell haw many input parameters were passed and modify the prgm./fn. behavior accordingly. As far as I know if you declared 3 parameters and enter while running the prgm./fn. two or one you will get error.
Thanks.

One idea would be to pass a single input -- a list. The list itself can contain however many objects (parameters) you want. You just need to add code to parse the list according to your needs.

Graph 3D | QPI | SolveSys
12-27-2013, 05:25 AM
Post: #4
 eried Senior Member Posts: 712 Joined: Dec 2013
RE: Control of input parameters in prgms./fns.
Other option is if TW adds optional parameters

Code:
EXPORT Name(required_var, required_var, optional_var=default, optional_var=default) BEGIN ...

My website: erwin.ried.cl
12-27-2013, 07:52 AM
Post: #5
 John P Member Posts: 191 Joined: Dec 2013
RE: Control of input parameters in prgms./fns.
Thank you all. I was thinking about adding one more real number parameter and the prgm. would check. If it would be for ex. 2 the program would use the two parameters I want and if it would be 1 prgm. would use one parameter etc.
06-05-2014, 06:16 PM
Post: #6
 John P Member Posts: 191 Joined: Dec 2013
RE: Control of input parameters in prgms./fns.
(12-27-2013 04:34 AM)Han Wrote:
(12-27-2013 02:26 AM)John P Wrote:  Is there any way, inside a program/function in HP Prime, to tell haw many input parameters were passed and modify the prgm./fn. behavior accordingly. As far as I know if you declared 3 parameters and enter while running the prgm./fn. two or one you will get error.
Thanks.

One idea would be to pass a single input -- a list. The list itself can contain however many objects (parameters) you want. You just need to add code to parse the list according to your needs.

I am re-asking the same question for the newest firmware. I dreamed that it changed. Did my dream come true or it is back to the same old reality.
Thanks for replays.
06-06-2014, 08:11 AM
Post: #7
 cyrille de brébisson Senior Member Posts: 844 Joined: Dec 2013
RE: Control of input parameters in prgms./fns.
hello,

Nope, sorry, no changes there...
using a list is still the only solution.
or having multiple functions, with slightly different names and different number of parameters.

PPL does not yet implement default parameters, nor var-args, not overloading...

Cyrille
06-06-2014, 01:00 PM
Post: #8
 John P Member Posts: 191 Joined: Dec 2013
RE: Control of input parameters in prgms./fns.
(06-06-2014 08:11 AM)cyrille de brébisson Wrote:  hello,

Nope, sorry, no changes there...
using a list is still the only solution.
or having multiple functions, with slightly different names and different number of parameters.

PPL does not yet implement default parameters, nor var-args, not overloading...

Cyrille

Thank you.
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)