# Gateway Event Scrip Issue

**URL:** <https://forum.inductiveautomation.com/t/gateway-event-scrip-issue/11596>\
**Category:** General Discussion\
**Created:** [April 28, 2016, 3:23pm UTC](https://forum.inductiveautomation.com/t/gateway-event-scrip-issue/11596 "2016-04-28T15:23:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_S](https://avatars.discourse-cdn.com/v4/letter/j/a9a28c/32.png) [@John\_S](https://forum.inductiveautomation.com/u/John_S)\
**Post date:** [April 28, 2016, 3:23pm UTC](https://forum.inductiveautomation.com/t/gateway-event-scrip-issue/11596/1 "2016-04-28T15:23:05Z")

</div>

I am new to Python and having problems coming up with a Gateway Event Script. I am wanting to write a string value to a memory tag pending the value of an OPC Tag. My idea is that there would be multiple “If” statements to accommodate for the numerous OPC Tag possibilities. Here is what I have so far but I cant get it to work.

if system.tag.value(“100 Series (South)/BG Number (FULL)”) == BG20873:  
system.tag.write (“100 Series (South)/Pallet Counter/Pallet Type”, GX12345)

Any help would be appreciated.

---

<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:** [April 28, 2016, 5:15pm UTC](https://forum.inductiveautomation.com/t/gateway-event-scrip-issue/11596/2 "2016-04-28T17:15:06Z")

</div>

There’s no such function as system.tag.value(). It’s 'system.tag.read(). However, it does return a qualified value, not the data value. So you have to add .value after the function. In your case, it becomes:`if system.tag.read("100 Series (South)/BG Number (FULL)").value == "BG20873":
   system.tag.write("100 Series (South)/Pallet Counter/Pallet Type", "GX12345")`You’ll note I also quoted BG20873 and GX12345. { I also put the code in [code] [/code] blocks so other forum viewers can see the indentation and alignment. }

But, why Python for this? Can you not create a simple database table with a column for BG Number and a column for Pallet Type? Then use a Query tag with`Select PalletType
From MyLookupTable
Where BGNumber='{MyOPCTag}'`

---

<div class="post-metadata">

**Author:** ![John\_S](https://avatars.discourse-cdn.com/v4/letter/j/a9a28c/32.png) [@John\_S](https://forum.inductiveautomation.com/u/John_S)\
**Post date:** [April 28, 2016, 5:50pm UTC](https://forum.inductiveautomation.com/t/gateway-event-scrip-issue/11596/3 "2016-04-28T17:50:40Z")

</div>

Thank you. That fixed it! I like the idea of the DB query. I was just trying to get something completed fairly quickly today and figured an If statement was a fast route.
