View previous topic :: View next topic
|
Author |
Message |
Ajeevlal
New User
Joined: 19 Feb 2005 Posts: 9 Location: Chennai
|
|
|
|
i have this below simple eztrieve program.
WS-VAR1 W 7 N VALUE 0
WS-VAR2 W 7 N VALUE 0
WS-DIFF W 7 N VALUE 0
JOB INPUT NULL
WS-VAR1 = 9
WS-VAR2 = 2
WS-DIFF = WS-VAR2 - WS-VAR1
DISPLAY 'WS-VAR2 ' WS-DIFF
IF WS-DIFF LE 0
DISPLAY ' LESS THAN '
ELSE
DISPLAY ' GREATER '
END-IF
STOP
The output of the above program is 7 (positive), actually 2-9 is -7. is there any way to identify negative values during computation in eztrieve. |
|
Back to top |
|
|
noorkh
New User
Joined: 06 Mar 2006 Posts: 76 Location: Chennai
|
|
|
|
Hi Ajeevlal,
User Masking to get Negative sign in output.
Remember for negative masking sign needs to be put after digits. |
|
Back to top |
|
|
Ajeevlal
New User
Joined: 19 Feb 2005 Posts: 9 Location: Chennai
|
|
|
|
thanks. i have tried using mask
WS-VAR1 W 7 N VALUE 0
WS-VAR2 W 7 N VALUE 0
WS-DIFF W 7 N VALUE 0 MASK 'ZZZZZ99-'
JOB INPUT NULL
WS-VAR1 = 9
WS-VAR2 = 2
WS-DIFF = WS-VAR2 - WS-VAR1
DISPLAY 'WS-VAR2 ' WS-DIFF
IF WS-DIFF LE 0
DISPLAY ' GREATER '
ELSE
DISPLAY ' LESS THAN '
END-IF
STOP
but still the same result. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Quote: |
If you specify a numeric field with no decimal positions, CA-Easytrieve/Plus considers that field unsigned |
Try
WS-DIFF W 7 N 0 VALUE 0 |
|
Back to top |
|
|
noorkh
New User
Joined: 06 Mar 2006 Posts: 76 Location: Chennai
|
|
|
|
Hi Ajeevlal,
I think it can be done only with Signed decimal field.
Try with WS-DIFF W 8 P 2 MASK 'Z,ZZZ,ZZZ,ZZZ,ZZ9.99-' VALUE 0. |
|
Back to top |
|
|
Ajeevlal
New User
Joined: 19 Feb 2005 Posts: 9 Location: Chennai
|
|
|
|
Thank you all guys.
both
WS-DIFF W 7 N 0 VALUE 0
and
WS-DIFF W 8 P 2 MASK 'Z,ZZZ,ZZZ,ZZZ,ZZ9.99-' VALUE 0.
worked well. |
|
Back to top |
|
|
|