Click here to Skip to main content
Click here to Skip to main content

Convert a Double to String: M3

, 12 Feb 2013
Rate this:
Please Sign up or sign in to vote.
Code to convert/format numeric value to alpha value in M3.

Since M3 Java code is similar to RPG and use MvxString rather than String, here is the code to convert/format numeric value to alpha value in M3.

1:  this.PXNUM = dSUM;
2:  this.PXALPH.clear();
3:  SRCOMNUM.COMNUM();
4:  WQT[tempIdx].moveRight(this.PXALPH);

In line number:

  1. Assign double value which is to be converted.
  2. Clear any previous value of PXALPH.
  3. Actual conversion. The SRCCOMNUM is an object of cSRCOMNUM class declared in mvx.app.util.
  4. Gets the converted alphanumeric value.

Let, dSUM= 38.05580 and if we want:

  • to display dSUM with two decimals:
  • 1:  this.PXNUM = dSUM; 
    2:  this.PXALPH.clear();   
    3:  this.PXDCCD = 2; // setting number of decimals.
    4:  SRCOMNUM.COMNUM(); 
    5:  WQT[tempIdx].moveRight(this.PXALPH);

    Output> 38.05

  • to display a negative value: Here we have an option for which character to be used for negative representations (i.e. –38.05, (38.55), 38.05- etc.)
  • 1:  this.PXNUM = dSUM; 
    2:  this.PXALPH.clear();   
    3:  this.PXDCCD = 2; 
    4:  SRCOMNUM.PXPNVB='('; // Left character if negative
    5:  SRCOMNUM.PXPNVA=')'; // Right character if negative
    6:  SRCOMNUM.COMNUM(); 
    7:  WQT[tempIdx].moveRight(this.PXALPH);

    Output> (38.05)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Kelum W. Ganegoda
Software Developer (Senior) Brandix Lanka Pvt Ltd.
Sri Lanka Sri Lanka
I’ve started my career in 2001 with Microsoft .net ver 1.0. I’m a MCSD for .net.
 
Currently, I’m working for Sri Lanka’s largest apparel exporter as a Software Engineer. All projects in .net, MS Sql Server, Biztalk Server, WCF and WPF. And also, I’m developing components to the ERP. In addition to that, I’ve involved to create architecture of ERP integration.
Follow on   Twitter

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web03 | 2.8.140821.2 | Last Updated 12 Feb 2013
Article Copyright 2013 by Kelum W. Ganegoda
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid