List as a function argument

Christie Widget Designer Version 6 - Q&A

Moderator: Moderator Group

Forum rules
When asking make sure to include the operating system and the revision of Widget Designer you are using.

List as a function argument

Postby dchelnokov » Mon Sep 04, 2017 1:26 pm

Dear All,
If we call a function with a list parameter, shall we always convert the argument into a local list variable explicitly in the function's body, like below:
if all_even_numbers(list_of_my_layers) = True {// do this...}
***
Function body: all_even_numbers(list_of_my_layers)
var list_of_elements = list_of_my_layers.toList
//do the check
//...
// return True or False


If there are options, could you please list :lol: them ?
Is that list passed to a function as a reference, or as a copy? So can a function change its list-argument, or it only works with a copy of the list?
dchelnokov
 
Posts: 8
Joined: Sat Feb 23, 2013 10:24 am

Re: List as a function argument

Postby dchelnokov » Tue Sep 05, 2017 5:32 pm

Experimenting I found that we need to assign the list-argument to a local variable and use the ".ToList" method at the end of the argument name. If you try to do anything with the raw argument, the WD will catch it as "non list variable".

I think that the List argument is a sort of pointer and I don't see the way to manipulate it in WD.
dchelnokov
 
Posts: 8
Joined: Sat Feb 23, 2013 10:24 am

Re: List as a function argument

Postby Janina Baltaziewicz » Wed Oct 11, 2017 3:34 pm

Hi,

That is true, you always have to convert your input parameters into the respective data type in the function (or macro) body before using it.
What you get there is a copy of the original input value, but packed in an "object" data type. That's why it isn't recognised as list or integer or whatever the original type was.

Cheers!

Janina
Janina Baltaziewicz
Customer Service Engineer
User avatar
Janina Baltaziewicz
 
Posts: 53
Joined: Tue Jun 14, 2016 2:08 pm

Re: List as a function argument

Postby dchelnokov » Tue Nov 07, 2017 4:01 pm

Thank you! :)
dchelnokov
 
Posts: 8
Joined: Sat Feb 23, 2013 10:24 am


Return to Widget Designer V6

Who is online

Users browsing this forum: No registered users and 13 guests