Friday, July 25, 2014

How to use D3 "EREPLACE" to help with variable character swaps in strings


I came across an issue where I needed to convert a single (1) character to two (2) characters and the normal CONVERT statement just did not cut it.

So I found this little command buried in the D3 docs called “EREPLACE”

It will convert a variable length string to another variable length string in a record, array or string.

Use:

In your code, you have to put in “$OPTIONS EXT” (without the quotes obviously) preferably in the top of the program where you might have $INCLUDE for instance.

Then you can use this command like this:

NSTRING = EREPLACE(“The new time is…”,”new”,”oldest”)
PRINT NSTRING

Which will print “The oldest time is…”


I hope you can use this in your D3 adventures.  

There might be other tricks out there, but this worked pretty well and it was very quick.

No comments:

Post a Comment