Overwriting sequence of an integer

This is probably a dumb question but Ive been struggling with it for days…

what would be the best way to overwrite only certian numbers in an Int2 tag?

for example if my PLC has a holding registers whos value is “1234” and I want to overwrite just the first two digits --> I want a numeric text field where I can enter “56” that would change the holding register from “1234” to “5634”

I seem to be unable to use any left or right string commands to write to my Int tag.

I tried creating 2 memory tags mapped to numeric text fields. then I created an Int2 expression tag with “concat({[~]New Tag},{[~]New Tag 1})” and wrote its value back to the OPC tag for my holding register… this seems to work but is extremely slow and this doesnt seem like the way it should be done.

Is there a good way to accomplish this?

Thank you in advance.

You can convert the integer to a string, take a portion of it, then append your beginning sequence then cast it back

int('56' + str(1234)[2:])

gbuehler - thank you very much!

this sent me in the right direction, below is what I entered in the script editor for an event handler to accomplish what I was looking for in the example.

hr = system.tag.getTagValue(‘HR43059’)
entry = event.source.parent.getComponent(‘Numeric Text Field 1’).intValue
hrstring = str(hr)
entrystring = str(entry)
valuestring = entrystring + (hrstring [2:])
value = int(valuestring)
system.tag.writeToTag(‘HR43059’, value)