1

This one has me wondering if I may be missing a function or something.

Have a string, example TZ118-AH01

I simply want to remove the second character and was wondering if there was a simple way of doing this, cannot use CONVERT as the second character may be repeated in the string.

Currently figuring I have to something like

VALUE = STRING[1,1]:STRING[3,LEN(STRING)-2]

Which seems a bit cumbersome.

Anyone have a nifty work around?

ScaryMinds
  • 335
  • 3
  • 11

1 Answers1

0
VALUE = STRING[1,1]:STRING[LEN(STRING)-2] 

Would be syntactically the same if you are sure that the length won't ever be less that 2, and if for some reason it does you don't mind stopping the entire call stack.

If the first and second characters are known commodities, you could use field and fudge up the field count in the forth variable to something high like 1000, but that is kludgy and relies on the first and second character not being the same.

The best was would be a function or subroutine to concatenate a new new string iterating through the character array and skipping the second iteration.

SUBROUTINE Remove2ndChar(StringOut,StringIn)
StringOut=""
CC=LEN(StringIn)
FOR C=1 TO CC
   If C NE 2 THEN 
      StringOut:=StringIn[C,1]
   END
NEXT C
RETURN

This is not necessarily what you are looking for, but it is probably going to be more execution safe.

Good Luck.

Van Amburg
  • 1,207
  • 9
  • 15