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.

New TIBCO Community Coming Soon
In early summer, TIBCO plans to launch a new community—with a new user experience, enhanced search, and expanded capabilities for member engagement with answers and discussions! In advance of that, the current myibi community will be retired on April 30. We will continue to provide updates here on both the retirement of myibi and the new community launch.

What You Need to Know about Our New Community
We value the wealth of knowledge and engagement shared by community members and hope the new community will continue cultivating networking, knowledge sharing, and discussion.

During the transition period, from April 20th until the new community is launched this summer, myibi users should access the TIBCO WebFOCUS page to engage.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Amper variable addition

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Amper variable addition
 Login/Join
 
Silver Member
posted
Hi,

I am trying to get the sum of amper variables using below code -

-SET &ECHO = ALL;
-SET &A=' 5.10';
-SET &B=' 10.05';
-SET &P=0.00;

-SET &P = &A.EVAL + &B.EVAL;
-TYPE &P

But I am losing decimal part of it.

Regards,

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


WF dev version - 7.6.x
 
Posts: 29 | Registered: February 15, 2006Report This Post
Platinum Member
posted Hide Post
Amper variables formats only can be alphanumeric or integer.
After arithmetic operations in Dialogue Manager, the decimal part is truncated.
To avoid this truncation, We can convert the result to alphanumeric format using FTOA function.

Try the example:

-SET &A ='5.10' ;
-SET &B = '10.05' ;
-SET &P = FTOA(&A+&B, '(D15.2)', 'A20'); 
-TYPE P = &P

Regards,
Mikel


WebFOCUS 8.1.05, 8.2.01
 
Posts: 173 | Location: Madrid, Spain | Registered: May 09, 2003Report This Post
Silver Member
posted Hide Post
Thanks Michel,

That worked for the code I had submitted. The problem is that if the result goes beyond 1000 it is not able as there is a comma that gets added to the result. for Example

-SET &A ='1000.10' ;
-SET &B = '10.05' ;
-SET &P = FTOA(&A+&B, '(D15.2)', 'A20');
-TYPE P = &P
-SET &Q = FTOA(&P+&B, '(D15.2)', 'A20');
-TYPE Q = &Q

In this P gets printed properly but for Q there is an error.

Any leads please....


WF dev version - 7.6.x
 
Posts: 29 | Registered: February 15, 2006Report This Post
Platinum Member
posted Hide Post
That's right.
Change format to D15.2c ("c" is the display option to avoid the comma on output).

-SET &A ='1000.10' ;
-SET &B = '10.05' ;
-SET &P = FTOA(&A+&B, '(D15.2c)', 'A20');
-TYPE P = &P
-SET &Q = FTOA(&P+&B, '(D15.2c)', 'A20');
-TYPE Q = &Q

Regards,
Mikel


WebFOCUS 8.1.05, 8.2.01
 
Posts: 173 | Location: Madrid, Spain | Registered: May 09, 2003Report This Post
Silver Member
posted Hide Post
Thanks Mikel.

It worked for me.

Regards,


WF dev version - 7.6.x
 
Posts: 29 | Registered: February 15, 2006Report This Post
Silver Member
posted Hide Post
I was trying to print last value of Q again with comma (number display). But not able to do that. Any idea???

please try below code

-SET &A ='-10000.10' ;
-SET &B = '10.05' ;
-SET &P = FTOA(&A+&B, '(D15.2c)', 'A20');
-TYPE P = &P
-SET &Q = FTOA(&P+&B, '(D15.2c)', 'A20');
-TYPE Q = &Q

I want to get Q as (-)9,980.00

Thanks.


WF dev version - 7.6.x
 
Posts: 29 | Registered: February 15, 2006Report This Post
Platinum Member
posted Hide Post
Again, remove the "c" only in the last step, when you need to display. Or you can add the following command:

-SET &Q = FTOA(&Q, '(D15.2)', 'A20') ;

Regards,
Mikel


WebFOCUS 8.1.05, 8.2.01
 
Posts: 173 | Location: Madrid, Spain | Registered: May 09, 2003Report This Post
Silver Member
posted Hide Post
Thanks Mikel,
It worked ... Smiler)

Regards,
Nitu


WF dev version - 7.6.x
 
Posts: 29 | Registered: February 15, 2006Report This Post
Virtuoso
posted Hide Post
Just what I was looking for....




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Platinum Member
posted Hide Post
Me too - works well.


_______________________
*** WebFOCUS 8.1.05M ***
 
Posts: 196 | Location: London, UK | Registered: December 06, 2005Report This Post
Virtuoso
posted Hide Post
It could be done with a little bit less code:
 
SET DMPRECISION = 2
-RUN
-SET &A=' 5.10';
-SET &B=' 10.05';
-SET &P = &A + &B;
-TYPE &P 


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
 
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007Report This Post
Platinum Member
posted Hide Post
Many thanks for the tip using SET DMPRECISION=2

What I was really having trouble with was the following:-

-SET &C = &A + &B ;
(where &A = 2222222222 and &B = 3333333333)
The result &C should be displayed as 5555555555
but instead shows as ******** (8 asterisks)
therefore by doing :-
-SET &D = FTOA(&A+&B, '(D10c)', 'A10');
you get the addition displaying correctly

Cheers...


_______________________
*** WebFOCUS 8.1.05M ***
 
Posts: 196 | Location: London, UK | Registered: December 06, 2005Report This Post
<JG>
posted
Just as a point of interest SET DMPRECISION was a new feature in 7.6.1.
 
Report This Post
Virtuoso
posted Hide Post
Based on a little experimentation, it appears that -SET has two different modes of operation when right-hand-side involves numbers.

1. -SET &var = a string of digits;
treats the string of digits as a character expression.

2. -SET &var = an expression involving an arithmetic operator;
evaluates the expression, and then effectively formats it using FTOA(result, '(F8)', 'A8'), if DMprecision is zero. If FTOA senses overflow, then '********' is stored in &var. But if result of the expression was out of range (not sure what that range is), the value fed to FTOA is reset to zero.

Parentheses can be either numeric or character operators, depending on context, so they do not of themselves transform the RHS into a "numeric" expression.

-SET &Z=123456789012345678901234567890;

-SET &Z1=(&Z);
-SET &Z2=0+(&Z);
-SET &Z3=&Z * 0.000000000000000000001;
-SET &Z4=&Z * 0.0000000000000000000001;

-SET &Z1L=&Z1.LENGTH;
-SET &Z1T=&Z1.TYPE;

-SET &Z2L=&Z2.LENGTH;
-SET &Z2T=&Z2.TYPE;

-SET &Z3L=&Z3.LENGTH;
-SET &Z3T=&Z3.TYPE;

-SET &Z4L=&Z4.LENGTH;
-SET &Z4T=&Z4.TYPE;

-? &Z


result

 -SET &Z=123456789012345678901234567890;
 -SET &Z1=(123456789012345678901234567890);
 -SET &Z2=0+(123456789012345678901234567890);
 -SET &Z3=123456789012345678901234567890 * 0.000000000000000000001;
 -SET &Z4=123456789012345678901234567890 * 0.0000000000000000000001;
 -SET &Z1L=30;
 -SET &Z1T=A;
 -SET &Z2L=01;
 -SET &Z2T=N;
 -SET &Z3L=08;
 -SET &Z3T=A;
 -SET &Z4L=08;
 -SET &Z4T=N;
 CURRENTLY DEFINED & VARIABLES STARTING WITH 'Z':
 &Z            = 123456789012345678901234567890
 
 &Z1           = 123456789012345678901234567890  // character-value assigned
 &Z1L          = 30
 &Z1T          = A

 &Z2           = 0            // numeric value obtained, result reset to zero
 &Z2L          = 01
 &Z2T          = N

 &Z3           = ********     // numeric value obtained, result overflowed I8 format, *'s stoted, marked as Alpha
 &Z3L          = 08
 &Z3T          = A

 &Z4           = 12345678     // result marked as numeric
 &Z4L          = 08
 &Z4T          = N


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Amper variable addition

Copyright © 1996-2020 Information Builders