Focal Point
[SOLVED] GETTOK

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

April 26, 2010, 04:41 PM
Malinda
[SOLVED] GETTOK
I am trying to extract the first part of the email address in order to develop a username. I know that there is a GETTOK function but am not sure how to use this with WebFocus Smiler

Malinda

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


WebFOCUS 7.6.11
Windows
all output (Excel, HTML, PDF)
April 26, 2010, 04:59 PM
GinnyJakes
Here is doc:

quote:
Syntax: How to Extract a Substring (Token)
GETTOK(infield, inlen, token_number, 'delim', outlen, outfield)
where:

infield
Alphanumeric

Is the field containing the parent character string.

inlen
Integer

Is the length of the parent string in characters. If this argument is less than or equal to 0, the function returns spaces.

token_number
Integer

Is the number of the token to extract. If this argument is positive, the tokens are counted from left to right. If this argument is negative, the tokens are counted from right to left. For example, -2 extracts the second token from the right. If this argument is 0, the function returns spaces. Leading and trailing null tokens are ignored.

'delim'
Alphanumeric

Is the delimiter in the parent string enclosed in single quotation marks. If you specify more than one character, only the first character is used.

Note: In Dialogue Manager, to prevent the conversion of a delimiter space character (' ') to a double precision zero, include a non-numeric character after the space (for example, '%'). GETTOK uses only the first character (the space) as a delimiter, while the extra character (%) prevents conversion to double precision.

outlen
Integer

Is the maximum size of the token. If this argument is less than or equal to 0, the function returns spaces. If the token is longer than this argument, it is truncated; if it is shorter, it is padded with trailing spaces.

outfield
Alphanumeric

Is the name of the field that contains the token, or the format of the output value enclosed in single quotation marks. The delimiter is not included in the token.


--------------------------------------------------------------------------------
Top of page
--------------------------------------------------------------------------------


Example: Extracting a Token From a Field
GETTOK extracts the last token from ADDRESS_LN3 and stores the result in LAST_TOKEN.

The delimiter is a space:

TABLE FILE EMPLOYEE
PRINT ADDRESS_LN3 AND COMPUTE
LAST_TOKEN/A10 = GETTOK(ADDRESS_LN3, 20, -1, ' ', 10, LAST_TOKEN);
AS 'LAST TOKEN,(ZIP CODE)'
WHERE TYPE EQ 'HSM';
END


You can find this either on the Help in Developer Studio or in the "Using Functions" manual.


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
April 26, 2010, 05:10 PM
Malinda
So then when I want to take out the first part (everything up until the @ which can very in length) of the email I would use
GETTOK(EMAIL,70,1,'@',20,USERNAME) then I could take the spaces out from there. We are using something like this in mainframe focus but wasn't sure if it wasn't different with WebFocus.

Thanks!
malinda


WebFOCUS 7.6.11
Windows
all output (Excel, HTML, PDF)
April 26, 2010, 05:17 PM
GinnyJakes
The subroutine should be the same.

As for removing spaces, do a search on this forum. There have been a number of techniques posted for removing a character from a string. I think I once used one posted by Francis M.


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
April 26, 2010, 05:31 PM
Malinda
Great thanks for the hints!


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