October 29, 2007, 04:08 PM
gwellerUsing strrep to replace a period
I am attempting to strip out the period located within my username to allow me to make a nice pretty title. Any thoughts on the problem behind this one? It complains about the period. It will work with other characters.
STRREP(&USR.LENGTH, '&USR.EVAL', 1, '.', 1, 'X', &USR.LENGTH, 'A&USR.LENGTH')
Error: INVALID TYPE OF ARGUMENT #4 FOR USER FUNCTION STRREP
October 29, 2007, 04:11 PM
gwellernevermind...
I searched on the error message and found this piece of advice.."Concat an empty string to the end to force into an alphanumeric" so...
STRREP(&USR.LENGTH, '&USR.EVAL', 1, '.' | '', 1, ' ' | '', &USR.LENGTH, 'A&USR.LENGTH');
October 29, 2007, 04:17 PM
Francis MarianiOr you could use CTRAN to replace one character by another.
-DEFAULT &USR = 'Francis.Mariani';
-SET &USR1 = CTRAN(&USR.LENGTH, &USR, BYTVAL('.','I2'), BYTVAL(' ','I2'), 'A&USR.LENGTH');
-TYPE &USR / &USR1
In my example, using BYTVAL avoids having to use the ASCII/EBCDIC decimal values for the character to be replaced and makes the CTRAN function platform-independent.
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
October 29, 2007, 05:10 PM
TravI don't know if this is the same issue or not, but we've had issues with "short" strings and using STRREP sometimes completely strips out all of the characters.
In the end, our solution is exactly what you've found -- concatenate some spaces to the end. I've always thought this strange, but for us it seemed to be more frequent on strings that were less than say 4 characters or so.