Convert a Double to String: M3





0/5 (0 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:
- Assign double value which is to be converted.
- Clear any previous value of
PXALPH
. - Actual conversion. The
SRCCOMNUM
is an object ofcSRCOMNUM
class declared in mvx.app.util. - 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
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)