# Passing kwargs into objectScript

**URL:** <https://forum.inductiveautomation.com/t/passing-kwargs-into-objectscript/18294>\
**Category:** Ignition\
**Created:** [June 5, 2018, 2:15am UTC](https://forum.inductiveautomation.com/t/passing-kwargs-into-objectscript/18294 "2018-06-05T02:15:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrew.brauer](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/andrew.brauer/32/34853_2.png) [@andrew.brauer](https://forum.inductiveautomation.com/u/andrew.brauer)\
**Post date:** [June 5, 2018, 2:15am UTC](https://forum.inductiveautomation.com/t/passing-kwargs-into-objectscript/18294/1 "2018-06-05T02:15:37Z")

</div>

I have seen @pturmel post about using Simulation Aids "objectScript" in place of runScript. I have been able to use the objectScript. So, I modified my original function to have keyworded arguments, like this:

> objectScript("shared.WorkOrder.SumCounters(\*args,\*\*kwargs)",{[.]../WE10602/Part\_CNT/Raw Reject},EnableOffset=1)

I was hoping to pass keyworded arguments, but this seems to fail. I was just wondering if this function was not designed to handle keyworded arguments. My function works in the script console. I was hoping that I could feed it into "objectScript".

I didn't see the documentation mention support for keyworded arguments.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 5, 2018, 2:51am UTC](https://forum.inductiveautomation.com/t/passing-kwargs-into-objectscript/18294/2 "2018-06-05T02:51:07Z")

</div>

There’s no support for keyword arguments because the expression language provides no hooks to expose the names of arguments like you’ve shown. However, you can explicitly assign values from the args tuple to specific keywords. There’s no reason you can’t embed the keyword like so:

```auto
objectScript("shared.WorkOrder.SumCounters(*args, EnableOffset=1)",{[.]../WE10602/Part_CNT/Raw Reject})

```

Or dynamically with something like this:

```auto
objectScript("shared.WorkOrder.SumCounters(*args[:-1], EnableOffset=args[-1])",{[.]../WE10602/Part_CNT/Raw Reject}, {Root Container......some Enable Property})

```

---

<div class="post-metadata">

**Author:** ![andrew.brauer](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/andrew.brauer/32/34853_2.png) [@andrew.brauer](https://forum.inductiveautomation.com/u/andrew.brauer)\
**Post date:** [June 5, 2018, 3:04am UTC](https://forum.inductiveautomation.com/t/passing-kwargs-into-objectscript/18294/3 "2018-06-05T03:04:34Z")

</div>

![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/f/fd8ed8a26171296703e0a3e8d3647602a97b01f7.png)

I have tried the first script, I can't seem to get this to work.

> SyntaxError: ("mismatched input 'EnableOffset' expecting DOUBLESTAR", ('expression:objectScript', 1, 45, '\_\_retv = shared.WorkOrder.SumCounters(\*args, EnableOffset=1)\n'))

The second script generates the same error. Is there something that I am missing?

I am using Ignition v7.9.7.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 5, 2018, 11:56am UTC](https://forum.inductiveautomation.com/t/passing-kwargs-into-objectscript/18294/4 "2018-06-05T11:56:03Z")

</div>

Whoops! Wildcard parameters must be last in the function call. Try this syntax:

```auto
shared.WorkOrder.SumCounters(EnableOffset=1, *args)

```

---

<div class="post-metadata">

**Author:** ![andrew.brauer](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/andrew.brauer/32/34853_2.png) [@andrew.brauer](https://forum.inductiveautomation.com/u/andrew.brauer)\
**Post date:** [June 6, 2018, 2:31am UTC](https://forum.inductiveautomation.com/t/passing-kwargs-into-objectscript/18294/5 "2018-06-06T02:31:24Z")

</div>

That worked! Thank you!.

The “objectScript” function is awesome!
