Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to assign decimal value to amper variable 1

Status
Not open for further replies.

2wayparadise

Programmer
Jan 24, 2007
7
US
How can I assign floating point value to amper variable, it only handle integer value

-SET &FV = 3.10;
-SET &FV = &FV + 0.25;
-TYPE &FV

and the result is 3 instead of 3.35

Any idea ?
 
The problem is, your calculation is done in Double Precision. All Dialogue Manager variables are stored as ALPHA. So, when we convert the Double Precision number to ALPHA, how many decimal positions should be stored? Should your result be 3.35, 3.350, 3.3500, etc?

With releases prior to 7.6, you can use a User Written Subroutine to do the calculation and conversion. The routine is called FTOA (Floating point TO Alpha). The first argument is your calculation (calculations are done FIRST when used as subroutine call arguments). The second argument is the FORMAT to convert the result to. It's enclosed in quotes since it's a literal, and the format is enclosed in parentheses. Remember, the format SHOULD be Double Precision, since the calculation is done that way, and you should account for any commas in the output length. The third argument is the output format, enclosed in single quotes.

Here's an example:
Code:
-SET &FV = 3.10;
-SET &FV = FTOA(&FV + 0.25,'(D6.2)','A6');
-TYPE &FV

This produced:

3.35 (note the leading blanks caused by the format)

With release 7.6 and later, you can SET how many decimal point digits you want with the new setting DMPRECISION (SET DMPRECISION=2 would result in 3.35)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top