Focal Point
Extract all Characters Before @ symbol in email address

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

July 15, 2008, 04:01 PM
Kymber
Extract all Characters Before @ symbol in email address
I want to grab every character before the ' @ ' symbol.

E.g jsimpson@usa.com

I want to grab 'jsimpson'

Can anyone point me in the right direction.

Thanks,

Kymber
July 15, 2008, 04:15 PM
Francis Mariani
Use the GETTOK character function.

In Dialogue Manager:

-*GETTOK(INFIELD, INLEN, TOKNUM, DELIM, OUTLEN, OUTFIELD)

-SET &EMAIL_ADD = 'duke.ellington@jazz.com';

-SET &EMAIL_ADD1 = GETTOK('&EMAIL_ADD.EVAL', &EMAIL_ADD.LENGTH, 1, '@', &EMAIL_ADD.LENGTH, 'A&EMAIL_ADD.LENGTH');

-TYPE &EMAIL_ADD1

In a DEFINE or COMPUTE statement:

EMAIL_ADD1/A40 = GETTOK(EMAIL_ADD, 200, 1, '@', 40, 'A40');



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
July 15, 2008, 04:31 PM
mgrackin
Use the GETTOK function.


Thanks!

Mickey

FOCUS/WebFOCUS 1990 - 2011
July 16, 2008, 04:21 PM
Kymber
DEFINE FILE FDATA
EMAILUSERID/A30 = EMAIL.EMAILADDRESS;
GETUSERID/A30 = GETTOK(EMAILUSERID, EMAILUSERID.LENGTH, 1,'@', EMAILUSERID.LENGTH, GETUSERID);
END
-RUN

TABLE FILE FDATA
PRINT
GETUSERID
WHERE TYPE EQ 'EMAIL';
WHERE GETUSERID EQ LOCASE(8,'&LOGASS','A8');
ON TABLE PCHOLD FORMAT PDF
END
-RUN

I am getting an error saying
(FOC003) THE FIELDNAME IS NOT RECOGNIZED: GETUSERID

Suggestions?

Kymber
July 16, 2008, 04:31 PM
Francis Mariani
You will have an error before the "(FOC003) THE FIELDNAME IS NOT RECOGNIZED: GETUSERID" error - only the first error is valid.

.LENGTH only works in Dialogue Manager. In FOCUS code, you have to specify the length as a numeric value:

DEFINE FILE CAR
EMAILUSERID/A30 = 'THIS.IS@TEST.COM';
GETUSERID/A30 = GETTOK(EMAILUSERID, 30, 1,'@', 30, GETUSERID);
END
-RUN

TABLE FILE CAR
PRINT
GETUSERID
COUNTRY
END
-RUN



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
July 16, 2008, 04:36 PM
Kymber
SOLUTION:

I hard coded the EMAILUSERID.LENGTH to 30 and I got the correct results.


Before:

GETUSERID/A30 = GETTOK(EMAILUSERID, EMAILUSERID.LENGTH, 1,'@', EMAILUSERID.LENGTH, GETUSERID);

After:

GETUSERID/A30 = GETTOK(EMAILUSERID, 30, 1,'@', 30, GETUSERID);

Magic!!!
July 16, 2008, 04:36 PM
Prarie
Well it does not like your define. You are using the -SET example that Fransis gave you...you should be using the DEFINE. You do not need the .LENGTH


In Focus since 1993. WebFOCUS 7.7.03 Win 2003
Thanks Francis...you were still there.


In Focus since 1993. WebFOCUS 7.7.03 Win 2003
Thanks Guys! Smiler
"AND" Prarie, a wonderful Gal from Texas!!!! Winky

This message has been edited. Last edited by: Tom Flynn,


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
quote:
... In FOCUS code, you have to specify the length as a numeric value

No longer true.
DEFINE FILE CAR
-* highjack a field to hold the email address:
 STANDARD= EDIT(MODEL,'9.gross@midwoodds.com');
-* these calls are invarient w/r/t change in declared length of the STANDARD field:
 USERID/A20 = GETTOK(STANDARD, LENV(STANDARD,'I2'), 1,'@', 20, USERID);
 DOMAIN/A20 = GETTOK(STANDARD, LENV(STANDARD,'I2'), 2,'@', 20, DOMAIN);
END

TABLE FILE CAR 
WRITE USERID DOMAIN 
BY CAR BY MODEL BY STANDARD
END

LENV() was introduced with varchar (AnV) fields, to provide access to the 'length of content' -- but it also accepts char (An) fields, returning the declared length.

This is useful for database fields whose length may be subject to change, and with 'A0' formal arguments in Maintain functions.


- Jack Gross
WF through 8.1.05