Passing declared local variables as input parameters

Discuss RoboTask here
Post Reply
juanlu
Posts: 48
Joined: Wed Jul 31, 2019 12:33 am

Passing declared local variables as input parameters

Post by juanlu »

Hi,

1) I have a task TASK_CALLER and a task TASK_PROCESSOR.

2) In the task TASK_PROCESSOR, I have explicitly declared (edit task -> tab "local variables") the variable VAR_TEST_BOOLEAN. It is not initialised (VAR_TEST_BOOLEAN=)

3) In the task TASK_CALLER I have a Start Task action calling the task TASK_PROCESSOR: Start Task "TASK_PROCESSOR".

4) In the action Start Task "TASK_PROCESSOR" I am passing a input parameter: VAR_TEST_BOOLEAN=true

5) When I run the TASK_CALLER, the value of VAR_TEST_BOOLEAN is displayed as empty (!). I was expecting true.

6) If I removed the explicit declaration in TASK_PROCESSOR and then run TASK_CALLER again, then the value of VAR_TEST_BOOLEAN is displayed as true.

@Oleg: is this the expedted behaviour?

I was convinced that: I) whatever you declared was the default value and II) the value would be replaced by a calling/input parameter.

Kind regards, Juanlu.
Oleg
Site Admin
Posts: 3011
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Passing declared local variables as input parameters

Post by Oleg »

is this the expedted behaviour?
Yes. Declaration hides the parameter with same name.
If you pass parameter you don't need variable declaration.
Declaration has the same effect as you set some value to variable at the 1-st step (before other steps of the task)
Oleg Yershov
juanlu
Posts: 48
Joined: Wed Jul 31, 2019 12:33 am

Re: Passing declared local variables as input parameters

Post by juanlu »

Thanks for the reply.

I understand the principle. But I have to say that it is not ideal. In other scripting languages, tools, etc it is common to have default values for parameters, which are overriden when this parameters are passed (if they are not passed, then they take the default values).

Perhaps this could be suggestion for a future release...

Kind regards, Juanlu.
Post Reply