Tuesday, August 26, 2014

D3 - Replace variable length 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.


Let me know if you have any questions.

No comments:

Post a Comment