Gateway Event Scrip Issue

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.

There’s no such function as system.tag.value(). It’s ' 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"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 withSelect PalletType From MyLookupTable Where BGNumber='{MyOPCTag}'

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.