Focal Point
NewB Question abour Formatting

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

January 09, 2006, 05:43 AM
rubenibi
NewB Question abour Formatting
Hi All!

I've been making a report, and no way it works. I have the following declaration:

 IDNOMBRE/A200=ID|'<a href=javascript:cargaDatos(' | COD_NIVEL | ',' | 
EDIT(COD_CENRES1) | ')>' | NOMBRE | '</a>'; 


Where COD_CENRES1 is a P7 format, and when I do the EDIT, it transforms to a number, so, if the packet of 7, is "12345", the nes COD_CENRES1 becomes 0012345, and in the Javascript function doesn´t crash, but takes this like an octal value.

Is there someway that COD_CENRES could be an integer without zeros?

Dunno if I have explained myself in a good way, I'm from Spain, and don't speak frequently English Roll Eyes

Regards

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



____________________________________________
Ruben Rueda
Consultant
Information Builders Iberica

Web: http://www.eruben.biz

Prod: WF 5.3.4 @ Red Hat Enterprise Linux ES 3 (Taroon Update 6) w/Oracle 9i
Test: WF 5.3.3 @ SUN Solaris 7 w/Oracle 8i
January 09, 2006, 06:50 AM
Tony A
Ruben,

Use the FTOA function. Firstly convert your P7 to an F7 and then use something like -

COD_CENRES1_F/F7 = COD_CENRES1;
COD_CENRES1_A/A7 = FTOA(COD_CENRES1_F,'(F7)','A7');

Good luck

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 
January 09, 2006, 07:05 AM
rubenibi
Mmm, ok, with that conversions I have a string, but what I want to do is to convert that string to integer, but the problem is if I use the EDIT function with that string generated, it creates a integer but it fills with zeros if the string coverted doesn't have the length I put, I mesn:

COD_CENRES1_F/F7 = COD_CENRES1;
COD_CENRES1_A/A7 = FTOA(COD_CENRES1_F,'(F7)','A7');
IDNOMBRE/A200=ID|'<a href=javascript:cargaDatos("' | COD_NIVEL | '","' 
| OD_CENRES1_A | '")>' | NOMBRE | '</a>';


If COD_CENRES1_A has the value now "123" and I do a
 COD_CENRES_INT/I7 = EDIT(COD_CENRES1_A)  
the value now would be 000123....

Know what I mean?

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



____________________________________________
Ruben Rueda
Consultant
Information Builders Iberica

Web: http://www.eruben.biz

Prod: WF 5.3.4 @ Red Hat Enterprise Linux ES 3 (Taroon Update 6) w/Oracle 9i
Test: WF 5.3.3 @ SUN Solaris 7 w/Oracle 8i
January 09, 2006, 08:07 AM
Tony A
Ruben,

Using the edit function on a numeric value will add the leading zeroes (as you have experienced) and provide you with an alphanumeric value. You have to have an alphanumeric value because you are including it into an alphanumeric DEFINE as you have discovered. That is why FTOA is the way to provide what you require.

Using FTOA will convert a floating point decimal value to an alphanueric value without those annoying leading zeroes. Once you have the result of the FTOA function you can include that in your DEFINE without the EDIT.

Using COD_CENRES_INT/I7 = EDIT(COD_CENRES1_A); should give you the result 123 in your example and not the leading zeroes unless you have SET LEADZERO=ON elsewhere in your fex.

Consider -
DEFINE FILE CAR
COD_CENRES1/P7 = 123;
COD_CENRES1_F/F7 = COD_CENRES1;
COD_CENRES1_A/A7 = FTOA(COD_CENRES1_F,'(F7)','A7');
COD_CENRES1_I/I7 = EDIT(COD_CENRES1_A);
IDNOMBRE/A200='<a href=javascript:cargaDatos("' | 
COD_CENRES1_A | '","' | COD_CENRES1_A | '")>' | COD_CENRES1_A | '</a>';
END
TABLE FILE CAR
PRINT COD_CENRES1 AS 'Packed'
      COD_CENRES1_F AS 'Float'
      COD_CENRES1_A AS 'Alpha'
      COD_CENRES1_I AS 'Integer'
      IDNOMBRE
      BY COUNTRY NOPRINT
IF RECORDLIMIT EQ 1
END


Copy and paste this into a new fex and run it. The output is -
Packed Float Alpha Integer  IDNOMBRE
   123   123 123       123  123

and the a href code will be -
<a href=javascript:cargaDatos("    123","    123")>    123</a>


T

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



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 
January 09, 2006, 08:11 AM
rubenibi
I've been playing with javascript too, so I've coded a little bit having this:

 COD_CENRES1_F/F7 = COD_CENRES1;
COD_CENRES1_A/A7 = FTOA(COD_CENRES1_F,'(F7)',COD_CENRES1_A);
IDNOMBRE/A200=ID|'<a href=javascript:cargaDatos("' | COD_NIVEL | '", 
parseInt("' | COD_CENRES1_A | '",10))>' | NOMBRE | '</a>';
 


If I refresh, and click right button/properties, the link is
 javascript:cargaDatos("A0", 
, doesn't appear complete, but if I see source code I have:
 <a href=javascript:cargaDatos("A0", parseInt("      0",10))>Algeciras                     
</a> 


But it gives me error when I click the link above, because of the spaces? Dunno Frowner

Any ideas?

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



____________________________________________
Ruben Rueda
Consultant
Information Builders Iberica

Web: http://www.eruben.biz

Prod: WF 5.3.4 @ Red Hat Enterprise Linux ES 3 (Taroon Update 6) w/Oracle 9i
Test: WF 5.3.3 @ SUN Solaris 7 w/Oracle 8i
January 09, 2006, 08:12 AM
Tony A
One point -

If you are using the values passed to your JavaScript function as integer values then you might need to lose the double quotes in your define -

IDNOMBRE/A200=ID|'<a href=javascript:cargaDatos("' | COD_NIVEL | '",' | 
COD_CENRES1_A | ')>' | NOMBRE | '</a>'


T

This message has been edited. Last edited by: Kerry,
January 09, 2006, 08:28 AM
rubenibi
This is the never ending post about formating haha...

Finally, I got:

 	COD_CENRES1_F/F7 = COD_CENRES1;
	COD_CENRES1_A/A7 = FTOA(COD_CENRES1_F,'(F7)','A7');
	COD_CENRES1_I/I7 = EDIT(COD_CENRES1_A);

-*  IDNOMBRE/A200=ID|'<a href=javascript:cargaDatos("' | COD_NIVEL | '", 
parseInt("' | COD_CENRES1_A | '",10))>' | NOMBRE | '</a>';
	IDNOMBRE/A200=ID|'<a href=javascript:cargaDatos("' | COD_NIVEL | '",' 
| COD_CENRES1_I | ')>' | NOMBRE | '</a>'; 


If I display these fields, FOCUS shows the values ok, but in Javascript not, why? I get in the second parameter some **** characters and doesn't look like that the function works properly.



Frowner

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



____________________________________________
Ruben Rueda
Consultant
Information Builders Iberica

Web: http://www.eruben.biz

Prod: WF 5.3.4 @ Red Hat Enterprise Linux ES 3 (Taroon Update 6) w/Oracle 9i
Test: WF 5.3.3 @ SUN Solaris 7 w/Oracle 8i
January 09, 2006, 11:23 AM
Tony A
Ruebn,

Read my last post and you will have your solution - i.e. get rid of the parseInt function in your JavaScript call, you do not need it. Just get rid of the double quotes around your second parameter.

IDNOMBRE/A200=ID|'<a href=javascript:cargaDatos("' | COD_NIVEL | '",' | 
COD_CENRES1_A | ')>' | NOMBRE | '</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 
January 09, 2006, 11:40 AM
rubenibi
No way it works Frowner

The only declaration that gimme no error is:

 IDNOMBRE/A200=ID|'<a href=javascript:cargaDatos("' | COD_NIVEL | '",' 
    | EDIT(COD_CENRES1) | ')>' | NOMBRE | '</a>'; 


The other with the converted formats gives javascript errors, that include:

 
-*IDNOMBRE/A200=ID|'<a href=javascript:cargaDatos("' | COD_NIVEL | '", 
    parseInt("' | COD_CENRES1_A | '",10))>' | NOMBRE | '</a>';

-*IDNOMBRE/A200=ID|'<a href=javascript:cargaDatos("' | COD_NIVEL | '",' 
    | COD_CENRES1_I | ')>' | NOMBRE | '</a>';

-*IDNOMBRE/A200=ID|'<a href=javascript:cargaDatos("' | COD_NIVEL | '",' 
    | COD_CENRES1_A | ')>' | NOMBRE | '</a>';
 

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



____________________________________________
Ruben Rueda
Consultant
Information Builders Iberica

Web: http://www.eruben.biz

Prod: WF 5.3.4 @ Red Hat Enterprise Linux ES 3 (Taroon Update 6) w/Oracle 9i
Test: WF 5.3.3 @ SUN Solaris 7 w/Oracle 8i
January 09, 2006, 01:49 PM
Francis Mariani
Ruben, if the problem is spaces in the JavaScript function call, try the following:

IDNOMBRE/A200=ID|'<a href=java_script:cargaDatos["' || COD_NIVEL || '",' || COD_CENRES1_A || ')>' || NOMBRE || '</a>';

Use "hard concatenation" instead of "soft concatenation" to eliminate leading spaces in Dialog Manager variables.

This message has been edited. Last edited by: Francis Mariani,


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
January 09, 2006, 03:10 PM
rubenibi
Francis Mariani you're right, tomorrow I'll use the other concatenation, and then I'll see what happen....

I'm going crazy with this!!

Thanks Francis Big Grin



____________________________________________
Ruben Rueda
Consultant
Information Builders Iberica

Web: http://www.eruben.biz

Prod: WF 5.3.4 @ Red Hat Enterprise Linux ES 3 (Taroon Update 6) w/Oracle 9i
Test: WF 5.3.3 @ SUN Solaris 7 w/Oracle 8i
January 10, 2006, 07:44 AM
rubenibi
At this moment I've been able to pass parameters ok, the solution I adopted is a mix of what we have written before.

Here goes:

My problem was calling a function in javascript created in a define table, one parameter must be alpha and the other one must be integer, but with several conversion, Javascript didn't transform any integer 00XXXX because of Javascript taked this value like octal.

So, the solution was trasnfors COD_CENRES1 from P7 to A7, after this, in the define I already can call parseInt Javascript function form transform an alphanumerical value to integer in base 10, since Javascript was playing in base octal, so the result is:

 IDNOMBRE/A200=ID|'<a href="javascript:cargaDatos('''|COD_NIVEL|''',
    parseInt('''|EDIT(COD_CENRES1)|''',10))">' | NOMBRE | '</a>'; 


Hope it helps in the future all this Wink

Thanks to everybody who helped me and give some ideas to this, many many thanks

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



____________________________________________
Ruben Rueda
Consultant
Information Builders Iberica

Web: http://www.eruben.biz

Prod: WF 5.3.4 @ Red Hat Enterprise Linux ES 3 (Taroon Update 6) w/Oracle 9i
Test: WF 5.3.3 @ SUN Solaris 7 w/Oracle 8i