Page 1 of 1
Defining Characters
Posted: Wed Jan 30, 2013 12:23 am
by Devx
I am writing a TI to load Attributes against an inventory item number in a dimension, but the data I want to load has trailing spaces, I have tried TRIM to remove these but after doing a ASCII extract to see the data I have found there is a "?" following the spaces.
This is creating issues with the Dimension and I want to be able to define this Character so that I can either remove it or make the attribute blank if it exists.
Is there any code that can be used to define a character at the end of a string?
Thanks
Re: Defining Characters
Posted: Wed Jan 30, 2013 12:49 am
by Martin Ryan
"?" can mean unprintable characters, but if you simply want to get rid of the last character in a string then "myStr=subst(myStr, 1, long(myStr)-2);" should do it (I think it's -2, not -1, but I may be mis-remembering). Then you can wrap a trim around that to get rid of the spaces.
HTH,
Martin
Re: Defining Characters
Posted: Wed Jan 30, 2013 12:59 am
by Alan Kirk
Dollars to donuts it's one of those accursed HTML non-breaking spaces. They're commonly picked up if the data source was originally a web page and unfortunately most Trim() type functions don't kill them.
The Ascii code is 160; you could use the Char() rules function to generate the character and feed it to the Scan() function to check for its presence in the data string. If you find it in the string then you could use the SubSt function suggested by Martin to rip out only the part of the string that is not the non-breaking space. I haven't tested this but it should work in theory.
Re: Defining Characters
Posted: Thu Jan 31, 2013 10:31 pm
by Devx
Alan / Martin
Thanks for your response, that has put me on the right track.