Focal Point
<SOLVED>Evaluating Fields for Special Characters

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

October 24, 2011, 09:02 AM
Tracie
<SOLVED>Evaluating Fields for Special Characters
I have a field in this format A:TEST:MONDAY and I only want A:TEST to display on the report. How do I evaluate the field to not display everything from the second colon on? Thanks

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


WebFocus 7703
Windows 7
Output format: HTML, Excel, PDF
October 24, 2011, 09:19 AM
Anatess
Look up GETTOK function.


WF 8.1.05 Windows
October 24, 2011, 11:02 AM
jfr99
Hi Tracie,

Here's an example using the CAR file.

T1_TXT - Your original field
T3_TXT - Your new field(Everything before the second Smiler

-*
DEFINE FILE CAR
T_KEY/I3 WITH MODEL = T_KEY + 1;
-*
T1_TXT/A200 = DECODE T_KEY (
1 'A:TEST:MONDAY'
2 'BB:TEST22:TUESDAY'
3 'CCC:TEST333:WEDNESDAY'
ELSE '**');
-*
T1_POS/I3 = POSIT(T1_TXT, 200, ':', 1, 'I3');
-*
T2_TXT/A200 = SUBSTR(200, T1_TXT, T1_POS+1, 200, 200, T2_TXT);
T2_POS/I3 = POSIT(T2_TXT, 200, ':', 1, 'I3');
-*
T3_LEN/I3 = T1_POS + T2_POS -1;
T3_TXT/A200 = SUBSTR(200, T1_TXT, 1, T3_LEN, 200, T3_TXT);
END
-*
TABLE FILE CAR
PRINT
T_KEY
-*
T1_TXT
T1_POS
-*
T2_TXT
T2_POS
-*
T3_LEN
T3_TXT
WHERE RECORDLIMIT EQ 3
END

~Jim


WebFocus 8.201M, Windows, App Studio
October 24, 2011, 11:07 AM
Doug
Or, (check out) CONTAINS. As in WHERE Field CONTAINS ':TEST:'.
October 24, 2011, 04:47 PM
Waz
I think GETTOK, POSIT then SUBSTR will do the job.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

October 25, 2011, 10:50 AM
njsden
If you *always* need to get everything just before the second ":", then tokenizing your field by ":" (using GETTOK as Anatess and Waz mentioned) and capturing the first 2 tokens would give the result you need.

-SET &TKNDEL=':';
DEFINE FILE CAR
FLD/A15 WITH CAR = 'A:TEST:MONDAY';
NEWFLD/A40 = GETTOK(FLD, 15, 1, '&TKNDEL', 15, 'A15') || '&TKNDEL' || 
             GETTOK(FLD, 15, 2, '&TKNDEL', 15, 'A15');
END
TABLE FILE CAR
PRINT CAR AND FLD AND NEWFLD
WHERE RECORDLIMIT EQ 1
END




Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
October 31, 2011, 01:06 PM
Tracie
Thank you for the information. I am all set.


WebFocus 7703
Windows 7
Output format: HTML, Excel, PDF