Hi,
I'm struggling a little with editing strings in iLogic. I have sets of part numbers that vary in length, but I'd like the part number to appear in another custom property with the last 6 characters trimmed off.
e.g.
Part Numbers: 12345_WXXXX
123456789_WXXXX
123_WXXXX
Desired Values in custom feild: 12345
123456789
123
I can write a line of code that keeps the last 6 characters but I can't get it to trim off the last six, because I don't know how many characters will be in the code before the last 6.
Hope it's something simple.
Thanks in advance
GavoGarmo
Solved! Go to Solution.
Solved by thomaskennedy. Go to Solution.
I've worked out a work around but I'm sure there must be a better way of doing it:
iProperties.Value("Project","Part Number") = "ABCDEFGHIJ_WXXX" iProperties.Value("Custom","REVNUM") = StrReverse(iProperties.Value("Project","Part Number")) iProperties.Value("Custom","REVNUMTRIM") = Mid(iProperties.Value("Custom","REVNUM"),6,20) iProperties.Value("Project","Stock Number") = StrReverse(iProperties.Value("Custom","REVNUMTRIM"))
Solved it with a bit of net searching:
In my case the "_" will always be there, so not quite a solution that will work for everyone but it might help someone.
If any one knows how to cut off the last 6 characters, no matter what charaters are used, I'd be really interested.
Thanks
iProperties.Value("Project","Stock Number") = iProperties.Value("Project","Part Number").Substring(0,iProperties.Value("Project","Part Number").IndexOf("_"))
You could use the Mid() function, but pass in the length of the string - 6 like this :
Mid(iProperties.Value("Project","Part Number"),1,Len(iProperties.Value("Project","Part Number"))-6)
Tom
Awesome! I like that a lot more than looking for the "_"
Thanks very much!