Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.



Read-Only Read-Only Topic
Go
Search
Notify
Tools
GETTOK
 Login/Join
 
Gold member
posted
Hi All,

Just wondering if anyone knows of an alternative within WebFOCUS to the defective GETTOK routine. For example, run this code:

-SET &STR = ',,HELLO,CRAZY,WORLD';
-SET &F1 = GETTOK(&STR,20,1,',',10,'A10');
-SET &F2 = GETTOK(&STR,20,2,',',10,'A10');
-SET &F3 = GETTOK(&STR,20,3,',',10,'A10');
-SET &F4 = GETTOK(&STR,20,4,',',10,'A10');
-SET &F5 = GETTOK(&STR,20,5,',',10,'A10');
-TYPE F1: &F1
-TYPE F2: &F2
-TYPE F3: &F3
-TYPE F4: &F4
-TYPE F5: &F5

and we get the following surprising result:

F1: HELLO
F2: CRAZY
F3: WORLD
F4:
F5:

Ask for token 1 and get token 3 (HELLO). Hmmmm.

In the past we've coded our own user written subroutine, HDRTOK, to work around the defects in GETTOK but we're wondering if there is an IBI supported alternative at this time.

-James


WF 7.1.6 moving to WF 7.7, Solaris 10, HTML,PDF,XL
 
Posts: 83 | Location: Dartmouth Hitchcock Medical Center | Registered: April 17, 2003Report This Post
Platinum Member
posted Hide Post
Hi James,
Try adding a space before the commas, like

-SET &STR = ' , ,HELLO,CRAZY,WORLD';


WebFOCUS 8202 Win 2012
Test - WebFOCUS 8203 on Win 2012
 
Posts: 173 | Registered: November 16, 2005Report This Post
Virtuoso
posted Hide Post
We use it all the time, but not in dialog manager commands and it works just fine.


Leah
 
Posts: 1317 | Location: Council Bluffs, IA | Registered: May 24, 2004Report This Post
Expert
posted Hide Post
you can use POSIT and SUBSTR if you're looking to search a string, and you're not sure exactly what to expect.
GETTOK has a specific purpose, for which it works just fine. You're trying to read nulls, not blanks. GETTOK is returning exactly what it is supposed to.
If you use POSIT and search for commas, you'll have explicit control.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Platinum Member
posted Hide Post
This MAY be a bug with gettok as I havle also used it for a long time. The same problem occurs with blanks too. See the table request using the car file below where I define another string with blanks instead of commas STR2. The same thing happens. This behavior seems to occur only when the token (blank or comma) happens to the first character in the string being parsed. As per RichH , inserting a blank before the commas at the beginning, and it works. The only thing I can say is that (kind of agreeing with Susannah) if I was to use it with blank as the token and I encountered a string where the first byte(S) were blank, the DESIRED RESULT in my opinion would be exactly what actually happens (F1 is "HELLO"). I also have to agree that this is not technically correct(F3 s/b "HELLO" as per jbmuir). This is most likely the reason I have never noticed this. Changing the "defective" routine would cause problems where in the past it was never noticed or was noticed and a code around was done. Maybe Art or Noreen would care to comment on this.


DEFINE FILE CAR
STR1/A24 WITH CAR =',,HELLO,CRAZY,WORLD';
STR2/A24 WITH CAR =' HELLO CRAZY WORLD';
F1/A10 = GETTOK(STR1,24,1,',',10,'A10');
F2/A10 = GETTOK(STR1,24,2,',',10,'A10');
F3/A10 = GETTOK(STR1,24,3,',',10,'A10');
F4/A10 = GETTOK(STR1,24,4,',',10,'A10');
F5/A10 = GETTOK(STR1,24,5,',',10,'A10');
F1A/A10 = GETTOK(STR2,24,1,' ',10,'A10');
F2A/A10 = GETTOK(STR2,24,2,' ',10,'A10');
F3A/A10 = GETTOK(STR2,24,3,' ',10,'A10');
F4A/A10 = GETTOK(STR2,24,4,' ',10,'A10');
F5A/A10 = GETTOK(STR2,24,5,' ',10,'A10');
END
TABLEF FILE CAR
PRINT F1 F1A OVER F2 F2A OVER F3 F3A OVER F4 F4A OVER F5 F5A
IF RECORDLIMIT EQ 1
END
PAGE 1


F1 HELLO F1A HELLO
F2 CRAZY F2A CRAZY
F3 WORLD F3A WORLD
F4 F4A
F5 F5A


FOCUS 7.6 MVS PDF,HTML,EXCEL
 
Posts: 115 | Location: Chicago, IL | Registered: May 28, 2004Report This Post
Gold member
posted Hide Post
Leah,

GETOK exhibits the same defect in a TABLE request. See this example:

DEFINE FILE CAR
LINE/A100 = ',,' || COUNTRY || ',' || CAR || ',' || MODEL;
END
TABLE FILE CAR
PRINT
LINE NOPRINT
COMPUTE
F1/A30 = GETTOK(LINE,30,1,',',30,'A30');
F2/A30 = GETTOK(LINE,30,2,',',30,'A30');
F3/A30 = GETTOK(LINE,30,3,',',30,'A30');
F4/A30 = GETTOK(LINE,30,4,',',30,'A30');
F5/A30 = GETTOK(LINE,30,5,',',30,'A30');
END
-RUN

Susannah,

I am trying to read tokens. If I specify token 3 I expect to get token 3 even if the first two tokens are null. GETTOK is the way it is because there are programs that have been written that depend on it's strange behaviour and nobody wants to fix GETTOK for fear of breaking lots of production code. That's fine. According to the documentation "GETTOK returns the token specified by the token_number". GETTOK is not returning exactly what it is supposed to. I'm not asking anyone to fix GETTOK, I'm just wondering if IBI has produced an alternative function that works.

RichH,

Thanks for the idea. It works, but I'm looking for a solution that doesn't require me to prefix my data with a blank.


-James


WF 7.1.6 moving to WF 7.7, Solaris 10, HTML,PDF,XL
 
Posts: 83 | Location: Dartmouth Hitchcock Medical Center | Registered: April 17, 2003Report This Post
Virtuoso
posted Hide Post
That's strange:

Here is what we do to extract names, of course there are two different tokens involve. Guess we don't do it the same way as the posted example.

TMP_NAME/A32 = GETTOK(AA003,32,2,',',32,TMP_NAME);
SFX_NAME/A5 = GETTOK(AA003,32,3,',',5,SFX_NAME);
FMN_NAME/A32 = LJUST(32,TMP_NAME,FMN_NAME);
FST_NAME/A32 = GETTOK(FMN_NAME,32,1,' ',32,FST_NAME);
LST_NAME/A32 = GETTOK(AA003,32,1,',',32,LST_NAME);
EXPNDNME/A72 = FST_NAME || (' ' | LST_NAME | ' ') || SFX_NAME || '*';
CMPRSNME/A32 = GETTOK(EXPNDNME,66,1,'*',32,CMPRSNME);


Leah
 
Posts: 1317 | Location: Council Bluffs, IA | Registered: May 24, 2004Report This Post
Guru
posted Hide Post
Try this. It's a bit long but it works.

-SET &STRING = ',,HELLO,CRAZY,WORLD';

-SET &STR_LNG = &STRING.LENGTH;
-SET &IDX = 1;
-SET &FNUM = 1;
-SET &PARSED_STR = '';

-LETSGO
-SET &CHARACTER = SUBSTR(&STR_LNG , &STRING, &IDX,
- &IDX, 1, 'A1');

-SET &FIELDU = BYTVAL(&CHARACTER, 'I3');

-IF &FIELDU EQ 44 THEN GOTO SETFLD ELSE GOTO SETSTR;

-SETSTR
-SET &PARSED_STR = &PARSED_STR||&CHARACTER;
-GOTO NEXT

-SETFLD
-IF &FNUM = 1 THEN GOTO SETTER1;
-IF &FNUM = 2 THEN GOTO SETTER2;
-IF &FNUM = 3 THEN GOTO SETTER3;
-IF &FNUM = 4 THEN GOTO SETTER4;
-SETTER1
-SET &F1 = &PARSED_STR;
-SET &PARSED_STR = '';
-SET &FNUM = &FNUM + 1;
-GOTO NEXT
-SETTER2
-SET &F2 = &PARSED_STR;
-SET &PARSED_STR = '';
-SET &FNUM = &FNUM + 1;
-GOTO NEXT
-SETTER3
-SET &F3 = &PARSED_STR;
-SET &PARSED_STR = '';
-SET &FNUM = &FNUM + 1;
-GOTO NEXT
-SETTER4
-SET &F4 = &PARSED_STR;
-SET &PARSED_STR = '';
-SET &FNUM = &FNUM + 1;
-GOTO NEXT

-NEXT
-SET &IDX = &IDX + 1;
-IF &IDX GT &STR_LNG THEN GOTO THATSALL ELSE GOTO LETSGO;

-THATSALL
-SETTER5
-SET &F5 = &PARSED_STR;
-SET &PARSED_STR = '';
-SET &FNUM = &FNUM + 1;
-TYPE Starting String: &STRING
-TYPE F1: &F1
-TYPE F2: &F2
-TYPE F3: &F3
-TYPE F4: &F4
-TYPE F5: &F5
-EXIT


Glenda

In FOCUS Since 1990
Production 8.2 Windows
 
Posts: 301 | Location: Galveston, Texas | Registered: July 07, 2004Report This Post
Expert
posted Hide Post
Nice Glenda, but why didn't you use STRREP instead? You're working too hard Wink
-SET &STR = ',,HELLO,CRAZY,WORLD' | '                           ';
-SET &STR = STRREP(&STR.LENGTH, '&STR.EVAL', 1, ',', 2, ' ,', &STR.LENGTH , 'A&STR.LENGTH');
-SET &F1 = GETTOK('&STR.EVAL',&STR.LENGTH,1,',',10,'A10'); 
-SET &F2 = GETTOK('&STR.EVAL',&STR.LENGTH,2,',',10,'A10'); 
-SET &F3 = GETTOK('&STR.EVAL',&STR.LENGTH,3,',',10,'A10'); 
-SET &F4 = GETTOK('&STR.EVAL',&STR.LENGTH,4,',',10,'A10'); 
-SET &F5 = GETTOK('&STR.EVAL',&STR.LENGTH,5,',',10,'A10'); 
-TYPE F1: &F1
-TYPE F2: &F2
-TYPE F3: &F3
-TYPE F4: &F4
-TYPE F5: &F5

This helps overcome the "defect" of ignoring tokens that are nulls by forcing a space into the position. Might need a little more work but it's a start .....

T

This message has been edited. Last edited by: Tony A,



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Guru
posted Hide Post
Because your way would take common sense and I don't seem to have much of that.

I'll certainly store your example away for future use.

Thanks


Glenda

In FOCUS Since 1990
Production 8.2 Windows
 
Posts: 301 | Location: Galveston, Texas | Registered: July 07, 2004Report This Post
Expert
posted Hide Post
quote:
STRREP
A new function in v7?


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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Guru
posted Hide Post
Apparently not. I cut and pasted the text and it ran like a charm. I'm on 5.3.6


Glenda

In FOCUS Since 1990
Production 8.2 Windows
 
Posts: 301 | Location: Galveston, Texas | Registered: July 07, 2004Report This Post
Expert
posted Hide Post
STRREP is one of those pre introduced items that appears to work on 5.3.2 and up but only got "introduced" with 7 onwards.

As the old saying goes - use it at your peril - so if you have problems in pre 7 then I don't think you'll get support for it Frowner

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Platinum Member
posted Hide Post
We had a similar problem. the length of 'HELLO,CRAZY,WORLD' is not 20 character but 17. The easiest way to get this is use the dialogue manager length property. in this case &STR.LENGTH. the code below


-SET &STR = 'HELLO,CRAZY,WORLD';
-SET &F1 = GETTOK(&STR,&STR.LENGTH,1,',',10,'A10');
-SET &F2 = GETTOK(&STR,&STR.LENGTH,2,',',10,'A10');
-SET &F3 = GETTOK(&STR,&STR.LENGTH,3,',',10,'A10');
-SET &F4 = GETTOK(&STR,&STR.LENGTH,4,',',10,'A10');
-SET &F5 = GETTOK(&STR,&STR.LENGTH,5,',',10,'A10');
-TYPE F1: &F1
-TYPE F2: &F2
-TYPE F3: &F3
-TYPE F4: &F4
-TYPE F5: &F5


Jim Morrow
Web Focus 7.6.10 under Windows 2003
MVS 7.3.3



 
Posts: 129 | Registered: June 01, 2005Report This Post
Expert
posted Hide Post
Jim,

Precisely, but the point was the two commas preceding the HELLO token. These get interpretted (correctly) as NULLS and therefore are not counted in the GETTOK token count. The only way to circumvent this is to fool the function by expanding the NULL to a space.

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic


Copyright © 1996-2020 Information Builders