Focal Point
[SOLVED] How to concatenate strings with single quote (apostrophe)

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

September 24, 2008, 12:14 PM
bug
[SOLVED] How to concatenate strings with single quote (apostrophe)
For examle, if &A=['abc','def'], and I code:

-SET &C=&A | &B;

The program will blow up because webfocus interprets it as

-SET &C='abc','def' | &B.

I tried QUOTEDSTRING and STRREP but neither works because the client is running ver 4.3.6.

What else can I do?

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


7.66 and 7.704
System: Windows / AIX / Linux
Output: Mostly HTML, with some PDF, Excel and Lotus(!)
September 24, 2008, 12:38 PM
Glenda
what about :
-SET &C = &A.EVAL&B.EVAL;



Glenda

In FOCUS Since 1990
Production 8.2 Windows
September 24, 2008, 12:44 PM
bug
quote:
Originally posted by Glenda:
what about :
-SET &C = &A.EVAL&B.EVAL;


Doesn't work. Same result as above.


7.66 and 7.704
System: Windows / AIX / Linux
Output: Mostly HTML, with some PDF, Excel and Lotus(!)
September 24, 2008, 12:45 PM
Francis Mariani
what is the value of &B?


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
September 24, 2008, 12:50 PM
Francis Mariani
This works in v5.3.2 and probably should in v4.3.6:

-SET &A = '''abc'',''def''';

-SET &B = 'XXX';

-SET &C = &A | &B;

-TYPE A: &A
-TYPE B: &B 
-TYPE C: &C 




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
September 24, 2008, 01:15 PM
j.gross
quote:
Originally posted by bug:
if &A=['abc','def'], and I code:
-SET &C=&A | &B;
The program will blow up because webfocus interprets it as
-SET &C='abc','def' | &B.


When it "blows up", what's your error message? What code is used to set &A and &B in the first place?

Note that the space before the | is essential; without the intervening space, the | just acts as a name delimiter, rather than a catenation operator.

This code:
  
-SET &ECHO=ALL;
-SET &xA='[''123'',''456'']';
-SET &xB='[''abc'',''def'']';
-? &x
-SET &xC= &xA | &xB ;
-? &x
-SET &xC= &xA| &xB ;
-? &x

...generates this echo:
 -SET &ECHO=ALL;
 -SET &xA='[''123'',''456'']';
 -SET &xB='[''abc'',''def'']';
 CURRENTLY DEFINED & VARIABLES STARTING WITH 'x':
 &xA           = ['123','456']
 &xB           = ['abc','def']
 -? &x
 -SET &xC= ['123','456'] | ['abc','def'] ;
 CURRENTLY DEFINED & VARIABLES STARTING WITH 'x':
 &xA           = ['123','456']
 &xB           = ['abc','def']
 &xC           = ['123','456']['abc','def']
 -? &x
 -SET &xC= ['123','456'] ['abc','def'] ;
 0 ERROR AT OR NEAR LINE     34  IN PROCEDURE _ADHOCRQFOCEXEC *
 (FOC261) EXPRESSION IS INCOMPLETE BECAUSE AN OPERATION IS MISSING



- Jack Gross
WF through 8.1.05
September 24, 2008, 02:08 PM
bug
OK, guys. I found something interesting here:

I was testing on MRE (the java applet) when I had the error. Error message was:

-SET &ABC= 'COM','FRM' | 'ABC' ;
0 ERROR AT OR NEAR LINE 24 IN PROCEDURE _CPMAccuFOCEXEC *
(FOC260) AN OPERATION IS MISSING AN ARGUMENT

However, when I test it in the web environment(ibiweb.exe?IBIF_ex=...), it works without any problem.

This can be closed. Thank you all for your help.


7.66 and 7.704
System: Windows / AIX / Linux
Output: Mostly HTML, with some PDF, Excel and Lotus(!)
September 24, 2008, 02:37 PM
Darin Lee
remember that single quote marks embedded in a string must be represented by two single quote marks. WebFOCUS treats two contiguous quotes within a quote-delimited string as a single literal quote. There's q pretty lengthy discussion of this in the "Developing Reporting Applications" manual under Customizing a Procedure With a Variable.


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
September 24, 2008, 03:02 PM
<JG>
quote:
-SET &ABC= 'COM','FRM' | 'ABC' ;


That should not work in any environment

Whtat's the comma doing?
September 25, 2008, 12:34 PM
PBrightwell
I'm with JG, I think it needs to be
-SET &ABC='''123','456'''|'''ABC''';


Pat
WF 7.6.8, AIX, AS400, NT
AS400 FOCUS, AIX FOCUS,
Oracle, DB2, JDE, Lotus Notes
September 25, 2008, 01:38 PM
j.gross
Seems that's just an execution echo, not the raw fex code. When showing a -SET statement, the echo mechanism shows the values rather than &var names on the RHS. Cf. my earlier response.

Why a problem with MRE and not for self-service? -- I wonder whether MRE's transcription process could cause | to be translated to something else ...


- Jack Gross
WF through 8.1.05
September 29, 2008, 04:27 PM
tlbrydie2
Bug,

Their are some characters that cause problems within Webfocue. I've encountered this same problem in our Self service applications. We basically take the ebcdic notation and convert code to another...allowable code. So you'll need the ebcdic chart for this method. Below is an example of converting a apostrophes to a graves.

Good Luck,

Timothy



  -* work-around for illegal special characters in a display amper-variable:
-* translate apostrophes to grave` and insert pipes after ampersands:
 AND COMPUTE INCHNAMX/A40=CTRAN(40,INCHNAM,39,96,'A40'); NOPRINT
 AND COMPUTE ZINCHNAM/A40=CTRAN(40,INCHNAMX,38,126,'A40');
 AND COMPUTE DOWNTOX/A20= CTRAN(20,DOWNGRDTO,39,96,'A20'); NOPRINT
 AND COMPUTE ZDOWNTO/A20= CTRAN(20,DOWNTOX,38,126,'A20');





Prod: WebFOCUS 7.6.10 MRE
Oracle/Sybase
Test: DevStudio 7.6.6
WF Server 7.6.6
Report Caster 7.6.6
Web Server - Tomcat
MS Windows XP SP2
Output: HTML, Excel 2000 , PDF, CSV, DOC

September 30, 2008, 02:22 AM
<JG>
As Timothy just said you need to use the CTRAN function

To do it in DM as opposed to a define or compute

-SET &A=''''||'123'||''''||','||''''||'456'||'''';
-SET &B=''''||'ABC'||''''||','||''''||'DEF'||'''';
-*
-SET &X=CTRAN(&A.LENGTH, &A, 39, 35, 'A&A.LENGTH');
-SET &Y=CTRAN(&B.LENGTH, &B, 39, 35, 'A&B.LENGTH');
-SET &AB =&X||','||&Y;
-SET &Z=CTRAN(&AB.LENGTH, &AB, 35, 39, 'A&AB.LENGTH');