Indirect tag binding in component script

in my project there is an event where user has to enter a value into the text field and that value will be used as index for referencing the tag for e.g. suppose user enters 1 than the indirect tag “Tank{index}/product_level” will be referenced accordingly with specified index number 1. is there a way to use indirect tag binding in component scripts?

It depends on how you will be using it but you can build the string and use that.

tankNum = system.gui.inputBox("Enter tank Number",1)
if tankNum != None:
     tagRef="Tank"+tankNum+"/product_level"
     server = "Ignition OPC-UA Server"
     path = tagRef
     qualifiedValue = system.opc.readValue(server, path)
     print "Value: " + str(qualifiedValue.getValue())
     print "Quality: " + qualifiedValue.getQuality().toString()
     print "Timestamp: " + qualifiedValue.getTimestamp().toString()
else:
     system.gui.errorBox("You must enter a valid tank number!","Error!")

hi,
i have created 100 tags of same type but different index number. now, i have provided user a drop down list (whose data property is binded with the MySQL table) from which he can select the desired entity. in my case, from drop down list user can select one of the available truck number in the database. if that truck is in under process in plant than its status is available in one of the 100 tags i have created. each time user select the truck from drop down list than, i have to cross verify it against tags. if it is present in the tag than the message will popup as “you can not add this truck as it is already under process”
now the problem is , i am using for loop for cross verifying this:
truckNo = event.source.parent.getComponent(‘TruckNO’).selectedStringValue
for x in range(1,101):
#y = toString(x) #tried to use this but gets an error as “toString is not defined”, if i dont use it i get an error as"cannot concatenate ‘str’ and ‘int’ objects"
path = “TT/TT”+x+"/szTruckNo" #this tas is created as string
value = system.tag.read(path)
if value == truckNo:
system.gui.messageBox(“already FAN pending for the truck!”,“Warning”)

see next message for the code i am using …sorry for indentation can not be seen for “for” and “if”

[quote=“roshanbhosale”]
truckNo = event.source.parent.getComponent(‘TruckNO’).selectedStringValue
for x in range(1,101): "
path = “TT/TT”+x+"/szTruckNo" #this tas is created as string
value = system.tag.read(path)
if value == truckNo:
system.gui.messageBox(“already FAN pending for the truck!”,“Warning”)[/quote]

You need to build the string using placeholders. %d is replaced with the value of x.

path = "TT/TT%d/szTruckNo"  % (x)