Concat Strings and create itemName out of it

All,

I have a string (“W_OWM_Temp”) and an int number (look0) and would like to create the item name out of them:
var tempS0 = "W_OWM_Temp" + look0.toString as GenericItem

Goal is to post an Update of this very item into another item like this:
W_OWM_TempDay0.postUpdate(tempS0.state)

but I already fail at as GenericItem:

Cannot cast from String to GenericItem

Any help would be greatly appreciated.

This might help:

I found that (I am checking for available threads of course) :wink:
That’s where I got the “as GenericItem” from.
But obviously I did not find the right syntax yet…

import org.eclipse.smarthome.model.script.ScriptServiceUtil
...

rule "something"
...
var tempS0 = "W_OWM_Temp" + look0.toString
val testItem = ScriptServiceUtil.getItemRegistry.getItem(tempS0)
W_OWM_TempDay0.postUpdate(testItem.state)
...

Thanks - I will give it a try.

This is essentially what Design Pattern: Associated Items is about.