How does Ignition implement basic slicing?

i have a coordinate container in which reside an input field, a label, and a button; firstName, outputTarget, and btn1 respectively. all i want is the first initial (or whatever slice of text) of the entered text. since the code below, which i have placed on the button's onClick event, throws an error, can you please tell me how Ignition wants us to do these kind of things?

#	get first initial of entered name
if (len(self.getSibling("firstName").props.text) > 0):
	self.getSibling("outputTarget").props.text = self.getSibling('firstName').props.text[0,1]

the error thrown is:

TypeError: unicode indices must be integers  #  umm... whut?

i even tried to decouple the thing and did this:

#	get first initial of entered name
if (len(self.getSibling("firstName").props.text) > 0):
	theFirst =  self.getSibling('firstName').props.text
	self.getSibling("outputTarget").props.text = theFirst[0,1]

but that didn't work either and i got the same error. last i checked both zero and one are integers...

as a final check, i straight-up assigned a string to the outputTarget and it displayed correctly, so i am targeting correctly.

thank you.

You are so close.... try using a : instead of ,

*facepalm* i need to get some sleep.... JS + Python + PHP + Ignition... and a deadline.

1 Like