# Curly braces, square brackets, parenthesis?

**URL:** <https://forum.inductiveautomation.com/t/curly-braces-square-brackets-parenthesis/75746>\
**Category:** Ignition\
**Created:** [June 29, 2023, 11:41pm UTC](https://forum.inductiveautomation.com/t/curly-braces-square-brackets-parenthesis/75746 "2023-06-29T23:41:37Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![eddie\_johnson](https://avatars.discourse-cdn.com/v4/letter/e/57b2e6/32.png) [@eddie\_johnson](https://forum.inductiveautomation.com/u/eddie_johnson)\
**Post date:** [June 29, 2023, 11:41pm UTC](https://forum.inductiveautomation.com/t/curly-braces-square-brackets-parenthesis/75746/1 "2023-06-29T23:41:37Z")

</div>

Is there a guide somewhere for what to use when and where? I have a script calling a named query, it works if I type in a value for the parameter. I can't get the formatting right to pass a value from a tag.

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [June 29, 2023, 11:55pm UTC](https://forum.inductiveautomation.com/t/curly-braces-square-brackets-parenthesis/75746/2 "2023-06-29T23:55:20Z")

</div>

When you say a script, do you mean a project script or a binding on a property? In the majority of cases you will encase it in `{}`, ie `{[System]Client/User/Country}`. In python scripts you encase the path in `"`, ie `tagPath = "[System]Client/User/Country"`

If you are calling it in a binding, and have it set as a query binding, select the parameter you want to use a tag to source and then press the little tag icon next to the parameters area  
 ![Untitled](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/e/ce1e7d2707c54e0e153f42ff499accaeaa239b5a.png)  
It should auto fill with the expected format.  
 ![Untitled2](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/6/065a14785754922834d126a82ce6890506ca3bd6.png)

If you are in an actual python script and calling `system.db.runNamedQuery` and trying to bring the value from a tag, you will need to make a call to `system.tag.readBlocking(["TagPathHere"])` and put the result into a dictionary where the keys match the names of the parameters for the named query.

---

<div class="post-metadata">

**Author:** ![eddie\_johnson](https://avatars.discourse-cdn.com/v4/letter/e/57b2e6/32.png) [@eddie\_johnson](https://forum.inductiveautomation.com/u/eddie_johnson)\
**Post date:** [June 30, 2023, 12:01am UTC](https://forum.inductiveautomation.com/t/curly-braces-square-brackets-parenthesis/75746/3 "2023-06-30T00:01:21Z")

</div>

I'm trying to call a named query from a button in Perspective. I'll post the script tomorrow when I have access to the gateway and designer again.

thanks for the response.

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [June 30, 2023, 12:20am UTC](https://forum.inductiveautomation.com/t/curly-braces-square-brackets-parenthesis/75746/4 "2023-06-30T00:20:35Z")

</div>

Then you are most likely in a python script. The following code should give you an idea of the general flow you should follow.

```auto
tagPaths = [
	"[provider]Path/To/Tag1",
	"[system]Path/To/Tag2"
]

response = system.tag.readBlocking(tagPaths)

value1 = response[0].value
value2 = response[1].value

queryResult = system.db.runNamedQuery("pathToQuery", {"param1": value1, "param2": value2})

self.session.custom.key=queryResult

```

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [June 30, 2023, 12:27am UTC](https://forum.inductiveautomation.com/t/curly-braces-square-brackets-parenthesis/75746/5 "2023-06-30T00:27:51Z")

</div>

> [@ryan.white](#):
>
> ```python
> response = system.tag.readBlocking(tagPaths)
> 
> value1 = response[0].value
> value2 = response[1].value
> 
> ```

You can also use the one-liner:

```python
value1, value2 = [qval.value for qval in system.tag.readBlocking(tagPaths)]

```

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [June 30, 2023, 6:34am UTC](https://forum.inductiveautomation.com/t/curly-braces-square-brackets-parenthesis/75746/6 "2023-06-30T06:34:33Z")

</div>

In scripts (actual scripts, not expressions), the language is jython (pretty much python running on java).  
There, the symbols are... python symbols. You can easily find a reference guide online, but basically:

Parenthesis: used either for a function definition/call, ie `function_name(parameters/arguments)` or for tuples: `days_of_the_week = ('monday', 'thursday', 'wednesday', [...])`. They can also be used for 'scoping' when indentation annoys you.  
For example `some_list = get_items().filter().sort().reverse()` could be written

```python
some_list = (
    get_items()
    .filter_it()
    .sort_it()
    .reverse_it()
)

```

or

```python
long_string = (
    "long line of text"
    " and another one"
    " that will be concatenated"
)

```

Which wouldn't work without the parentheses.

Square brackets are used for accessing values in data structures, for example `some_list[3]` will access the fourth element in the list (indexing is zero-based), `some_dict['key']` will access the `key` element in a dictionary...  
They can also be used to make lists: `[1, 2, 3, 4]` will create a list with those 4 elements.  
You'll often see brackets surrounding expression like this `[x*2 for x in range(12)]`. This is called a list comprehension. What's inside is a generator expression, and the results it yields are used to create a list. It's equivalent to `list(x*2 for x in range(12))`

Curly braces are _pretty much_ the equivalent of brackets, but for dictionaries or sets.  
`{1, 2, 1, 3, 1, 4, 2, 3}` will create a set containing 1, 2, 3, 4.  
`{'name': "foo", 'value': 42}` will create a dictionary with the key/value pairs `name = foo` and `value = 42`  
Can be used in comprehensions just like brackets for lists.

In expressions, parentheses are used for function calls.  
brackets are used to access data structure elements, for example `some_dataset[row_numer, column_name]`  
And curly braces, the ones you'll see the most, are used to note that the value inside is a path to a value defined somewhere else, and will be replaced by the value it references. {[default]some/path} will get the value of the tag `some/path` in the `default` tag provider. `{session.custom.foo}` will be the session custom property `foo`. `{view.parameters.bar}` will be the value of the parameter `bar` passed to the view.

You'll get more details, use cases, etc in the inductive university. I highly encourage you to go through it. It takes a little while, because it has a lot to teach, but it's worth it.  
There's also the doc, which is frankly quite good.

---

<div class="post-metadata">

**Author:** ![eddie\_johnson](https://avatars.discourse-cdn.com/v4/letter/e/57b2e6/32.png) [@eddie\_johnson](https://forum.inductiveautomation.com/u/eddie_johnson)\
**Post date:** [June 30, 2023, 11:16am UTC](https://forum.inductiveautomation.com/t/curly-braces-square-brackets-parenthesis/75746/7 "2023-06-30T11:16:51Z")

</div>

This works

#Call Named Query to Delete Selected Recipe  
param = {"SelectedRecipeName":"junk"}  
system.db.runNamedQuery("Rec\_DeleteSelected",param)

This doesn't  
def runAction(self, event):  
#SetUp Tag Variable Name  
varTag = ["[default]L8\_/Recipe/L8\_RecipeName"]  
#Read In Tag Value  
tagValue = system.tag.readBlocking(varTag)  
#Set Parameter Value for SelectedRecipeName To Use In Named Query  
param = {"SelectedRecipeName":tagValue}  
#Call Named Query to Delete Selected Recipe  
system.db.runNamedQuery("Rec\_DeleteSelected",param)

---

<div class="post-metadata">

**Author:** ![eddie\_johnson](https://avatars.discourse-cdn.com/v4/letter/e/57b2e6/32.png) [@eddie\_johnson](https://forum.inductiveautomation.com/u/eddie_johnson)\
**Post date:** [June 30, 2023, 11:22am UTC](https://forum.inductiveautomation.com/t/curly-braces-square-brackets-parenthesis/75746/8 "2023-06-30T11:22:49Z")

</div>

I see my missing step now!

value0 = tagValue[0].value

THANK Y'ALL!

---

<div class="post-metadata">

**Author:** ![eddie\_johnson](https://avatars.discourse-cdn.com/v4/letter/e/57b2e6/32.png) [@eddie\_johnson](https://forum.inductiveautomation.com/u/eddie_johnson)\
**Post date:** [June 30, 2023, 12:32pm UTC](https://forum.inductiveautomation.com/t/curly-braces-square-brackets-parenthesis/75746/9 "2023-06-30T12:32:06Z")

</div>

One more new issue but part of the same goal (recipes).  
/L8\_RecipeName is a string tag and the others are floats.  
I get the error " Error trying to coerce 'huh' to a number.".

```auto
def runAction(self, event):
#SetUp Tag Variable Name
	varTag = ["[default]L8_/Recipe/L8_RecipeName","[default]L8_/Recipe/L8_Rec_Ing1","[default]L8_/Recipe/L8_Rec_Ing2","[default]L8_/Recipe/L8_Rec_Ing3","[default]L8_/Recipe/L8_Rec_Ing4","[default]L8_/Recipe/L8_Rec_Ing5","[default]L8_/Recipe/L8_Rec_Ing6","[default]L8_/Recipe/L8_Rec_Ing7","[default]L8_/Recipe/L8_Rec_Ing8","[default]L8_/Recipe/L8_Rec_Ing7"]
#Read In Tag Value
	tagValue = system.tag.readBlocking(varTag)
#Reference Item
	value0 = tagValue[0].value
	value1 = tagValue[0].value
	value2 = tagValue[0].value
	value3 = tagValue[0].value
	value4 = tagValue[0].value
	value5 = tagValue[0].value
	value6 = tagValue[0].value
	value7 = tagValue[0].value
	value8 = tagValue[0].value
	value9 = tagValue[0].value
#Set Parameter Value for SelectedRecipeName To Use In Named Query
	params = {"ParRecipeName":value0,"ParCloser":value1,"parFiller":value2,"ParJuicer":value3,"ParInfeedAuger":value4,"ParSpiral":value5,"ParSpiralInfeed":value6,"ParSiraldischarge":value7,"ParHopperShaker":value8,"ParInfeedCanBelt":value9}
#Call Named Query to Save Recipe

	system.db.runNamedQuery("Rec_InsertData",params)

```

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [June 30, 2023, 12:49pm UTC](https://forum.inductiveautomation.com/t/curly-braces-square-brackets-parenthesis/75746/10 "2023-06-30T12:49:19Z")

</div>

Edit your post and wrap your code in triple backticks or use the preformatted text tool.  
This is hard to read.

---

<div class="post-metadata">

**Author:** ![eddie\_johnson](https://avatars.discourse-cdn.com/v4/letter/e/57b2e6/32.png) [@eddie\_johnson](https://forum.inductiveautomation.com/u/eddie_johnson)\
**Post date:** [June 30, 2023, 1:33pm UTC](https://forum.inductiveautomation.com/t/curly-braces-square-brackets-parenthesis/75746/11 "2023-06-30T13:33:30Z")

</div>

Sorry for my ignorance, no comprende

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [June 30, 2023, 1:34pm UTC](https://forum.inductiveautomation.com/t/curly-braces-square-brackets-parenthesis/75746/12 "2023-06-30T13:34:15Z")

</div>

> [@eddie\_johnson](#):
>
> no comprende

- Hit the pencil icon below each of your posts.
- Select the code block.
- Then press the \</\> button.

---

<div class="post-metadata">

**Author:** ![eddie\_johnson](https://avatars.discourse-cdn.com/v4/letter/e/57b2e6/32.png) [@eddie\_johnson](https://forum.inductiveautomation.com/u/eddie_johnson)\
**Post date:** [June 30, 2023, 1:45pm UTC](https://forum.inductiveautomation.com/t/curly-braces-square-brackets-parenthesis/75746/13 "2023-06-30T13:45:33Z")

</div>

I got it now. Y'alls help has been invaluable

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [June 30, 2023, 1:50pm UTC](https://forum.inductiveautomation.com/t/curly-braces-square-brackets-parenthesis/75746/14 "2023-06-30T13:50:00Z")

</div>

You're using the same value for every parameter. Clearly that's not what you meant to do ?

Anyway, cleaned up version of that script, using values sequentially instead of always the same:

```python
def runAction(self, event):
	tagPaths = [
		"[default]L8_/Recipe/L8_RecipeName",
		"[default]L8_/Recipe/L8_Rec_Ing1",
		"[default]L8_/Recipe/L8_Rec_Ing2",
		"[default]L8_/Recipe/L8_Rec_Ing3",
		"[default]L8_/Recipe/L8_Rec_Ing4",
		"[default]L8_/Recipe/L8_Rec_Ing5",
		"[default]L8_/Recipe/L8_Rec_Ing6",
		"[default]L8_/Recipe/L8_Rec_Ing7",
		"[default]L8_/Recipe/L8_Rec_Ing8",
		"[default]L8_/Recipe/L8_Rec_Ing7"
	]

	values = [qval.value for qval in system.tag.readBlocking(tagPaths)]
	keys = [
		"ParRecipeName",
		"ParCloser",
		"parFiller",
		"ParJuicer",
		"ParInfeedAuger",
		"ParSpiral",
		"ParSpiralInfeed",
		"ParSiraldischarge",
		"ParHopperShaker",
		"ParInfeedCanBelt"
	]
	params = dict(zip(keys, values))
	system.db.runNamedQuery("Rec_InsertData", params)

```
