# Passing parameter from project script

**URL:** <https://forum.inductiveautomation.com/t/passing-parameter-from-project-script/43786>\
**Category:** Ignition\
**Tags:** perspective, scripting\
**Created:** [February 24, 2021, 2:57pm UTC](https://forum.inductiveautomation.com/t/passing-parameter-from-project-script/43786 "2021-02-24T14:57:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![michael.black](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@michael.black](https://forum.inductiveautomation.com/u/michael.black)\
**Post date:** [February 24, 2021, 2:57pm UTC](https://forum.inductiveautomation.com/t/passing-parameter-from-project-script/43786/1 "2021-02-24T14:57:51Z")

</div>

I have a function in the project script where I am trying to change the value of a parameter on a popup view. Its related to visibility for a label. I have a button which runs the function and its supposed to change the visibility on the label. Using the system.util.logger I have confirmed the correct value is being determined based on the script, however it is not actually changing the visibility of the label.

For the view I have a parameter called LblNoGoVis and have it bidirectional. I am defining that parameter as lblNoGoVis in the call to the script and including that as a parameter that is passed into the function.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/0/60dd3956e64819c2fd5b9b491171d29ff0dc05bb.png)

Here is the script I am calling.

```auto
def download_to_cell(cell_id,new_recipe,label_vis):
	"""Check if its a new recipe. If so check for 9999 in memory cells
	
	Param:
		cell_id (str): Id designation of cell
		new_recipe (bool): Is this new recipe
		label_vis: visibility of message telling operator to edit recipe
	"""
	myBad = 0
	logger = system.util.getLogger("myLogger")
	
	if new_recipe:
		logger.info("New Recipe")
		counter = 1
		while counter < 36:
			#counterToString = counter.toString()
			memTag = '[{}]/Cell/Recipe/Memory/{}'.format(cell_id,str(counter))
			q1 = system.tag.read(memTag)
			memVal = q1.value
			if memVal == 9999:
				logger.info("Value is 9999")
				myBad = 1
				label_vis = "true"
				logger.info(label_vis)
				break
			else:
				counter = counter + 1
	
	if myBad == 0:
		value = 1
		label_vis = "false"
		logger.info(label_vis)
		myTag = '[{}]/Cell/Control/Recipe DownLoad/Request'.format(cell_id)
		system.tag.write(myTag, value)
		system.perspective.navigate(page = '/Machine')

```

The logger.info(label\_vis) is correctly giving me either true or false based on the function but it is not changing the actual parameter on the view. I do have the visibility of the label binded to the view parameter correctly. What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [February 24, 2021, 3:21pm UTC](https://forum.inductiveautomation.com/t/passing-parameter-from-project-script/43786/2 "2021-02-24T15:21:16Z")

</div>

You aren’t actually doing anything to change the visibility, you’re just modifying the `download_to_cell` function’s local `label_vis` variable.

That parameter is passed by value to the function, meaning it’s essentially just a copy of the boolean value at the time you called the function.

---

<div class="post-metadata">

**Author:** ![michael.black](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@michael.black](https://forum.inductiveautomation.com/u/michael.black)\
**Post date:** [February 24, 2021, 3:24pm UTC](https://forum.inductiveautomation.com/t/passing-parameter-from-project-script/43786/3 "2021-02-24T15:24:43Z")

</div>

Is there a way to have it change the parameter on the view? Is it possible to change values of things (other than writing to tags) from project scripts outside of putting this script directly on the button instead of in the project scripting?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [February 24, 2021, 3:25pm UTC](https://forum.inductiveautomation.com/t/passing-parameter-from-project-script/43786/4 "2021-02-24T15:25:52Z")

</div>

Make the parameter the label component itself and then modify the property by doing `label.meta.visible = False` or whatever.

---

<div class="post-metadata">

**Author:** ![michael.black](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@michael.black](https://forum.inductiveautomation.com/u/michael.black)\
**Post date:** [February 24, 2021, 5:09pm UTC](https://forum.inductiveautomation.com/t/passing-parameter-from-project-script/43786/5 "2021-02-24T17:09:33Z")

</div>

Could you elaborate? I have taken the binding off of the view parameter. Still not working. What would I have to change? Thanks

---

<div class="post-metadata">

**Author:** ![chandler](https://avatars.discourse-cdn.com/v4/letter/c/e9a140/32.png) [@chandler](https://forum.inductiveautomation.com/u/chandler)\
**Post date:** [March 1, 2021, 4:29pm UTC](https://forum.inductiveautomation.com/t/passing-parameter-from-project-script/43786/6 "2021-03-01T16:29:27Z")

</div>

@michael.black You need to pass the Label object to your function as the parameter rather than passing in the label’s visibility property as the parameter. an example function might look like this:

```auto
def func(label):
    label.meta.visible = False

```

and assuming that you are calling this function from a component script of a component that is a sibling of your label in the component hierarchy you could then call it like this:

```auto
myLabel = self.getSibling('theNameOfMyLabel')
func(myLabel)

```

The visibility property was not being changed because when you pass a boolean to a function in python, your parameter is a reference to the immutable True object or the immutable False object. When you change the parameter, the object itself isn’t changed, the parameter is just changed to refer to a different object. When you pass the label in directly, the label object is mutable, so changing the visibility property via the reference to the label object does actually change the object, so the changes made to the object are retained outside the function.
