Focal Point
Parsing string by semicolon

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

June 07, 2007, 01:01 AM
Sayed
Parsing string by semicolon
How can I parse a character field by ;

FOCUS does not seem to like
LAST_NAME/A30 = GETTOK(NAME, 30, -1, ';', 30, LAST_NAME);

These are possible values for the character field NAME

N/A;N/A
FIRST_NAME;N/A
N/A;LAST_NAME
FIRST_NAME;LAST_NAME

I need to divide the NAME field to FIRST_NAME and LAST_NAME field where FIRST_NAME and LAST_NAME field does not contain 'N/A' or ';'

Any help achieving this would be greatly appreciated.

Thank You in advance.


WF 8.x and 7.7.x Win/UNIX/AS400, MRE/Portal/Self-Service, IIS/Tomcat, WebSphere, IWA, Realmdriver, Active Directory, Oracle, SQLServer, DB2, MySQL, JD Edwards, E-BIZ, SAP BW, R/3, ECC, ESSBASE
June 07, 2007, 02:50 AM
Tony A
Sayed,

I get no problems with this -
FILEDEF NAMEMAS DISK NAMETAB.MAS
FILEDEF NAMETAB DISK NAMETAB.TXT
-RUN

-WRITE NAMEMAS FILE=NAMETAB,SUFFIX=FIX
-WRITE NAMEMAS SEGNAME=SEG1
-WRITE NAMEMAS FIELD=NAME_DATA,,A80,A80,$

-WRITE NAMETAB N/A;N/A
-WRITE NAMETAB FIRST_NAME;N/A
-WRITE NAMETAB N/A;LAST_NAME
-WRITE NAMETAB FIRST_NAME;LAST_NAME
-RUN

TABLE FILE NAMETAB
PRINT *
      COMPUTE LAST_NAME/A30 = GETTOK(NAME_DATA, 30, -1, ';', 30, LAST_NAME);
END
-RUN

What error message are you getting? Is the format of your field variable (AnnV)?

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 
June 07, 2007, 03:02 AM
Sayed
quote:
COMPUTE LAST_NAME/A30 = GETTOK(NAME_DATA, 30, -1, ';', 30, LAST_NAME);



Thanks Tony! Clear mistake of DEFINE vs. COMPUTE. I was trying trying to do this on DEFINE.


WF 8.x and 7.7.x Win/UNIX/AS400, MRE/Portal/Self-Service, IIS/Tomcat, WebSphere, IWA, Realmdriver, Active Directory, Oracle, SQLServer, DB2, MySQL, JD Edwards, E-BIZ, SAP BW, R/3, ECC, ESSBASE
June 07, 2007, 04:42 AM
Alan B
Sayed

No mistake between DEFINE and COMPUTE.

If an expression works in COMPUTE, it will work in DEFINE and vice versa.


Alan.
WF 7.705/8.007
June 07, 2007, 05:35 AM
Tony A
Sayed,

Are you saying that once you put it into a compute it worked?

As Alan states, there should be no problem with either. Did you have a semi-colon missing on the previous line in your define?

This is why it is important to state the error number (at least) and the message with this type of question.

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 
June 07, 2007, 09:31 AM
Francis Mariani
Tony,

This creation of a Master file on the fly is brill! Never thought of doing this - opens up new possibilities.

Thanks.


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
June 07, 2007, 10:37 AM
Tony A
Francis,

I do it a lot of the time when I need a particular master for a McGyver type technique or trying to help folks using their data.

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 
June 07, 2007, 10:59 AM
Sayed
OK I think I see the problem.
This is what I was trying

DEFINE FILE USNOTES

TEAMUS/A51 = GETTOK(TEAM, 51, 1, ';', 51, TEAMUS);

END

TABLE FILE USNOTES
PRINT
TEAM
TEAMUS
END

It works fine when you run it but DevStudio GUI tool does not like semicolon on the DEFINE statement. You get a popup window saying "Semicolns are not allowed".


WF 8.x and 7.7.x Win/UNIX/AS400, MRE/Portal/Self-Service, IIS/Tomcat, WebSphere, IWA, Realmdriver, Active Directory, Oracle, SQLServer, DB2, MySQL, JD Edwards, E-BIZ, SAP BW, R/3, ECC, ESSBASE