Focal Point
GETTOK

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

December 29, 2004, 09:54 PM
vaayu
GETTOK
TABLE FILE MYFILE
PRINT
MY_LOC
COMPUTE JCITY/A20 = GETTOK(MY_LOC, 52, -2, ' ', 30, JCITY);
WHERE READLIMIT EQ 10
WHERE RECORDLIMIT EQ 10
END

SAMPLE VALUES FOR MY_LOC/a52=3928 MyStreet MyCity MyState with space as delimiter.
I just need to get MYCITY MYSTATE. but it wont returns nothing when i say -2.Is there anyother way to extract those strings with delimiters as space.
Am i missing something here?
Please help!!!
BTW: Im using WF 5.23 and running some adhoc stuff.

Thx in advance
December 29, 2004, 11:36 PM
vaayu
Susanah,
Although it does look like its not a space but I had a space as delimiter i mean it was a ' ' in my argument.
Also, I tried the following:
TABLE FILE SOMEFILE
PRINT STOR_LOC
COMPUTE JCITY/A52 = GETTOK(STOR_LOC, 52, -2, ' ', 52, 'A52');
COMPUTE TESTPOSIT/I2=POSIT(STOR_LOC, 52, ' ', 2, 'I2');
COMPUTE TESTPARAG/A52=PARAG(52, STOR_LOC, ',', 52, TESTPARAG);

the output was (with a | between columns):
STOR_LOC |JCITY |TESTPOSIT |TESTPARAG

718 AVE G KENTWOOD LA | |4 |718 AVE G KENTWOOD LA

It basically dint return any data for JCITY and I dont know how to use POSIT to find if I can actually get the substring I need to extract.

From the above values I just need to extract KENTWOOD LA in my field JCITY.

Please help!!!

Thx a bunch!
December 30, 2004, 01:22 AM
susannah
ah! i figured out whats going on.
You need to RJUST your MY_LOC variable first, if you're going to want to token thru it from the right (that -2). Otherwise, you're finding the first blank, which is at the end of the input left-adjusted original string anyway. So that's why you're getting nada in your output. You can actually RJUST your input , or ...
Say your input field is A15, then
-SET &MYVAR = 'KENTWOODbLAbbbb'; (those b are blanks, ok?)
-SET &HOWLONG=ARGLEN(15, &MYVAR, 'I2');
-SET &STATE=GETTOK(&MYVAR , &HOWLONG, -1, ' ', &HOWLONG, 'A2');
-* Using the ARGLEN function determines just how long the string really is within the field space.
In this case &HOWLONG is 11.
So, telling GETTOK to read just 11 characters will bring you back the LA.