Focal Point
[CLOSED] GETTOK CTRAN and STRREP

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

June 08, 2015, 01:33 PM
Al_C
[CLOSED] GETTOK CTRAN and STRREP
I have a string which is actually several fields separated by a euro symbol (dec 128).

I wanted to use GETTOK to separate the fields, but GETTOK only returns the first field. My alternate strategy was to replace the euro characters with an asteriks, but that didn't work either.

what perplexes me is we also have decimal 253 characters that translate fine in all 3 commands

I'd appreciate any suggestions...

any way these are the 3 commands that fail to produce the results I want

(in define)
STR/A2000 = CTRAN(2000, STR1, 128, 42, STR);
STR/A2000 = STRREP(2000, STR1, 1, '€', 1, '*', 2000, STR);
STR/A100 = GETTOK(STR, 2000, 1, '€', 1, STR);
STR2/A100 = GETTOK(STR, 2000, 2, '€', 1, STR2);




this is a sample of my string
RýD€TG52132€SU/SP€FXSUSP€FAWI€2012ý2013ý2014€€A

This message has been edited. Last edited by: <Kathryn Henning>,


WebFOCUS 7.6.9
Windows
all output (Excel, HTML, PDF)
June 08, 2015, 01:54 PM
RSquared
you are using the same name for 3 different fields.

Try changing the field names to STR1, STR2,STR3 etc.
Use the GETTOK on the correct field
STR2/A100 = GETTOK(STR, 2000, 1, '€', 100, STR2);
STR3/A100 = GETTOK(STR, 2000, 2, '€', 100, STR3); and so on.


WF 7.6.11
Oracle
WebSphere
Windows NT-5.2 x86 32bit
June 08, 2015, 02:11 PM
Al_C
sorry for that typo

here are the commands

STR2/A100 = GETTOK(STR1, 2000, 1, '€', 100, STR2);
STR3/A100 = GETTOK(STR1, 2000, 2, '€', 100, STR3);


and the results

str2 (same as the original string)


Y€€€Henry Ford College€5105 Evergreen Rd.€Dearborn, MI 48128€KJ C€N€€€€€€€Y€Y€N€€€€€R€002270€G02270€€2015€Y€N€RýD€TG52132€SU/SP€FXSU/SP€FA/WI€2012ý2013ý2014€€ATTNPTTN€UG€CR€NONAUDIT€FQREGCR1ýFXSTATUSýFQNOATT€2€HS€MAIN€002270€002270€32574048€€€€00227000€€kjc@hfcc.edu€(313) 845-9616€€€€€DEFAULT€(313) 845-9825€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€100€€Y€3€€32574048€32574048€32574048€€P€RA€RA€32574048€N€2€2€€4€2€4€4€4€Y€Y€FADL€H€H€PREFERRED€CA€MX€US€€ISIM.PERSON€€Y€€€€€Y€€€€€2€€€€€€Y%


and string3

Y€€€Henry Ford College€5105 Evergreen Rd.€Dearborn, MI 48128€KJC€N€€€€€€€Y€Y€N€€€€€R€00

100 characters (- name removed for show & tell)

ignores the euro sign


WebFOCUS 7.6.9
Windows
all output (Excel, HTML, PDF)
June 08, 2015, 02:31 PM
Al_C
above
str1 is the original
str2 in the result of the first gettok and
str3 is empty the resuilt of the second gettok


WebFOCUS 7.6.9
Windows
all output (Excel, HTML, PDF)
June 08, 2015, 03:25 PM
Dan Satchell
It appears the € symbol is being used both as a delimiter and as filler. GETTOK is probably confused by finding many delimiters in a row. You could try something like this:

1. Use STRREP to replace all spaces with some character you know will never appear in the data ($,~,#,%,^,*, etc.)
2. Use STRREP to replace all € with a space.
3. Use SQUEEZ to compress all occurrences of multiple spaces into one space.
4. Use STRREP to replace all spaces with €.
5. Use STRREP to replace the character you chose for step 1 with a space.
6. You should now be able to use GETTOK to parse the string using € as the delimiter because all multiple occurrences of € should have been reduced to a single one.


WebFOCUS 7.7.05
June 09, 2015, 06:23 AM
Al_C
I'm starting to think that the problem is somehow with the character set. The euro symbol is a decimal 128 in the data string. (I copied and pasted the euro symbol from the data string into my report code).
Problem is, if I go into code and hold [alt] down and type 128 on the keypad I get a different character than the euro sign.(it looks like the euro sign is not part of the character set we are using - I tried all 255, and got no euro sign). Is it possible to change the character set somewhere?


WebFOCUS 7.6.9
Windows
all output (Excel, HTML, PDF)
June 09, 2015, 09:51 AM
GavinL
I might be missing something, but I threw this together and it worked fine..

-SET &STRIN = 'Y€€€Henry Ford College€5105 Evergreen Rd.€Dearborn, MI 48128€KJ C€N€€€€€€€Y€Y€N€€€€€R€002270€G02270€€2015€Y€N€RýD€TG52132€SU/SP€FXSU/SP€FA/WI€2012ý2013ý2014€€ATTNPTTN€UG€CR€NONAUDIT€FQREGCR1ýFXSTATUSýFQNOATT€2€HS€MAIN€002270€002270€32574048€€€€00227000€€kjc@hfcc.edu€(313) 845-9616€€€€€DEFAULT€(313) 845-9825€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€100€€Y€3€€32574048€32574048€32574048€€P€RA€RA€32574048€N€2€2€€4€2€4€4€4€Y€Y€FADL€H€H€PREFERRED€CA€MX€US€€ISIM.PERSON€€Y€€€€€Y€€€€€2€€€€€€Y%' ; 
-SET &SEP = '€';
-SET &STROUT = STRREP (&STRIN.LENGTH, &STRIN, &STRIN.LENGTH, &SEP, 1, '$', &STRIN.LENGTH, 'A&STRIN.LENGTH');

-TYPE STRIN - &STRIN 
-TYPE STROUT - &STROUT 




- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
June 09, 2015, 12:27 PM
Dan Satchell
Have you tried using the BYTVAL function to get the decimal equivalent?

-SET &ASCII_CODE = BYTVAL('€','I3');
-TYPE &ASCII_CODE



WebFOCUS 7.7.05
June 10, 2015, 07:15 AM
Al_C
I might try the byteval solution.

what worked is this:
TESTCHAR/A1 = EDIT(STR1,'$9');
STR/A2000 = STRREP(2000, STR1, 1, TESTCHAR, 1, '*', 2000, STR);

a cheesy way of doing things, but the first field is y/n and I know the second character will always be the euro sign.
Why the command works with the character extracted from the string itself but not by comparing decimal equivalents is a mystery


WebFOCUS 7.6.9
Windows
all output (Excel, HTML, PDF)
June 10, 2015, 07:18 AM
Al_C
Gavint

I tried your solution, and if I just type that in, it works for me too. Same thing with real data fails.

go figure


WebFOCUS 7.6.9
Windows
all output (Excel, HTML, PDF)