Focal Point
(Solved) - limitations of STRREP

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/5687092196

May 10, 2019, 09:35 AM
Troy_proffitt
(Solved) - limitations of STRREP
I am using dialogue manager to replace a "^" character with a "&" character, but the variable that is being used is over 5000 characters in length and it's failing:

-SET &parm_list = STRREP(&REPORTPARAMETERS.LENGTH,&REPORTPARAMETERS,1,'&',1,'^',&REPORTPARAMETERS.LENGTH,'A&REPORTPARAMETERS.LENGTH');

This will work up to 4000 characters, but fails if the &REPORTPARAMETERS value is any longer.

We are using both WF version 8005 and 8105, but it seems to fail on either version.

any ideas?

This message has been edited. Last edited by: Troy_proffitt,


WF version 8105
all output
May 10, 2019, 09:43 AM
BabakNYC
Would REPLACE work in this case?

https://webfocusinfocenter.inf...r/source/replace.htm


WebFOCUS 8206, Unix, Windows
May 10, 2019, 10:27 AM
Troy_proffitt
I just tested in both 8009 and 8105 and that function isn't available.


WF version 8105
all output
May 10, 2019, 11:20 AM
MartinY
May be a pain, but what if you split your variable into two (or more) of 4000 char (or less) each, then perform the STRREP to each and merge them back into one var ?
-SET &MAXLEN  = 25;
-SET &POS2    = &MAXLEN + 1;
-SET &LONGSTR = 'ABCDEFG^HIJKLMN^OPQRSTU^VWXYZ12^3456789^0';

-SET &LEN_STR = &LONGSTR.LENGTH;
-IF &LEN_STR GT &MAXLEN THEN GOTO SPLITSTR;

-SET &TSTR    = TRIMV('T', &LONGSTR, &LONGSTR.LENGTH, ' ', 1, 'A&LONGSTR.LENGTH');
-SET &LONGSTR = STRREP(&TSTR.LENGTH, &TSTR, 1, '^', 1, '&', &TSTR.LENGTH, 'A&TSTR.LENGTH');
-GOTO ENDREPLSTR

-SPLITSTR
-SET &SPLIT1  = SUBSTR(&LONGSTR.LENGTH, &LONGSTR,  1, &MAXLEN, &MAXLEN, 'A&MAXLEN.EVAL');
-TYPE SPLIT1: &SPLIT1<--
-SET &NSPLIT1 = STRREP(&SPLIT1.LENGTH, &SPLIT1, 1, '^', 1, '&', &SPLIT1.LENGTH, 'A&MAXLEN.EVAL');
-TYPE NSPLIT1: &NSPLIT1<--

-SET &SPLIT2  = SUBSTR(&LONGSTR.LENGTH, &LONGSTR, &POS2, &LONGSTR.LENGTH, &MAXLEN, 'A&MAXLEN.EVAL');
-TYPE SPLIT2: &SPLIT2<--
-SET &TSPLIT2 = TRIMV('T', &SPLIT2, &SPLIT2.LENGTH, ' ', 1, 'A&SPLIT2.LENGTH');
-SET &NSPLIT2 = STRREP(&TSPLIT2.LENGTH, &TSPLIT2, 1, '^', 1, '&', &TSPLIT2.LENGTH, 'A&TSPLIT2.LENGTH');
-TYPE NSPLIT2: &NSPLIT2<--

-SET &LONGSTR = &NSPLIT1 || &NSPLIT2;

-ENDREPLSTR
-TYPE NEW LONGSTR: &LONGSTR<--



WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
May 10, 2019, 11:24 AM
Troy_proffitt
I assume, you'd have to change :
-SET &SPLIT1 = SUBSTR(&LONGSTR.LENGTH, &LONGSTR, 1, 4000, 4000, 'A4000');
-SET &SPLIT2 = SUBSTR(&LONGSTR.LENGTH, &LONGSTR, 4001, &LONGSTR.LENGTH, 4000, 'A4000');

correct?


WF version 8105
all output
May 10, 2019, 11:46 AM
Doug
Have you considered CTRAN?
The CTRAN function translates a character within a character string to another character based on its decimal value. This function is especially 
useful for changing replacement characters to unavailable characters, or to characters that are difficult to input or unavailable on your keyboard. It can also be used for inputting 
characters that are difficult to enter when responding to a Dialogue Manager -PROMPT command, such as a comma or apostrophe. It eliminates the need to enclose entries in single 
quotation marks (').

To use CTRAN, you must know the decimal equivalent of the characters in internal machine representation. Note that the coding chart for conversion is platform dependent, hence your 
platform and configuration option determines whether ASCII, EBCDIC, or Unicode coding is used. Printable EBCDIC or ASCII characters and their decimal equivalents are listed in 
Character Chart for ASCII and EBCDIC.

In Unicode configurations, this function uses values in the range:

 ♦ 0 to 255 for 1-byte characters.
 ♦ 256 to 65535 for 2-byte characters.
 ♦ 65,536 to 16,777,215 for 3-byte characters.
 ♦ 16,777,216 to 4,294,967,295 for 4-byte characters (primarily for EBCDIC).

May 10, 2019, 12:13 PM
MartinY
quote:
Originally posted by Troy_proffitt:
I assume, you'd have to change :
-SET &SPLIT1 = SUBSTR(&LONGSTR.LENGTH, &LONGSTR, 1, 4000, 4000, 'A4000');
-SET &SPLIT2 = SUBSTR(&LONGSTR.LENGTH, &LONGSTR, 4001, &LONGSTR.LENGTH, 4000, 'A4000');

correct?

Yes, but the way I wrote the code I made it more flexible using parameters &MAXLEN, &POS2.
So, you don't need to change numbers at several places
I also insure that the string have no spaces at the end. What you are doing when you are keeping all the variables with a fix length of 4000


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
May 10, 2019, 12:17 PM
Doug
Here's the result from using CTRAN:
*** parm_list In : I need to replace all "^" character with a "&" character, in a 5000+ character variable. "^" ***
*** parm_list Out: I need to replace all "&" character with a "&" character, in a 5000+ character variable. "&" ***

May 10, 2019, 02:13 PM
Hallway
quote:
Have you considered CTRAN?


To echo Doug, I was able to use that function on a parameter that is 25,600 in length:
  
-SET &PARAMETER = 'Lorem^ipsum^dolor^sit^ut^amet^consectetur^adipiscing^elit^sed^do^eiusmod^tempor^incididunt^ut^labore';

-REPEAT LABEL 8 TIMES
-SET &PARAMETER = '&PARAMETER.EVAL&PARAMETER.EVAL';
-LABEL 

-TYPE ***BEFORE***
-TYPE PARAMETER: &PARAMETER;
-TYPE LENGTH: &PARAMETER.LENGTH;

-SET &LEN = &PARAMETER.LENGTH;
-SET &PARAMETER = CTRAN(&LEN, &PARAMETER.QUOTEDSTRING, 94, 38, 'A&LEN.EVAL');

-TYPE ***AFTER***
-TYPE PARAMETER: &PARAMETER;
-TYPE LENGTH: &PARAMETER.LENGTH;



Hallway

 
Prod: 8202M1
Test: 8202M4
Repository:
 
OS:
 
Outputs:
 
 
 
 
May 10, 2019, 02:17 PM
Hallway
I found this site to get the ASCII decimal numbers from: https://ascii.cl/


Hallway

 
Prod: 8202M1
Test: 8202M4
Repository:
 
OS:
 
Outputs:
 
 
 
 
May 14, 2019, 10:29 AM
Hallway
If this has corrected the issue that you were facing, please change the post title to include [Solved].


Hallway

 
Prod: 8202M1
Test: 8202M4
Repository:
 
OS:
 
Outputs:
 
 
 
 
May 15, 2019, 09:16 AM
Troy_proffitt
I tried out the CTRAN code and it works perfectly! Thanks for the help.


WF version 8105
all output