Page 1 of 1

### blank in a numeric field

Posted: Mon Jun 19, 2017 1:20 pm
Hello
Why Natural treets a blank in a numeric field like a zero value?!

DEFINE DATA
LOCAL
1 #F          (N3)
1 REDEFINE #F
2 #N1        (N1)
2 #A2        (A1)
2 #N3        (N1)
END-DEFINE
#N1:= 1
RESET #A2
DISPLAY #F
IF #F = 100
WRITE '!!!' '=' #F
END-IF
#F :=   #F * 2
DISPLAY #F
END

#F
----

1 0
!!! #F:  1 0
200

Thanks

### Re: blank in a numeric field

Posted: Mon Jun 19, 2017 7:17 pm
It depends upon what Natural does internally. If numeric values are converted from zoned decimal to packed decimal for operations, then blanks are X'40' and the first 4 bits (the zone) will be ignored and only the second 4 bits will be treated as the value -- and since a zero is X'F0' you cannot tell the difference between a blank and a zero once the value is packed.

### Re: blank in a numeric field

Posted: Fri Jan 19, 2018 1:22 am
You are redefining a numeric field. The alphabetic fields are allowed to help the development. the null value on the alphabetic field is transformed on the null value fot the numeric field. If you tried to put any letter it will fail in the moment you use the numeric field. Also you are not using the concept correctly.

This would be the normal use of it:

DEFINE DATA
*
LOCAL
*
1 #DATE (N8)
1 REDEFINE #DATE
2 #DATE-Y (N4)
2 #DATE-M (A2)
2 #DATE-D  (N2)
*
END-DEFINE
*
#DATE := 20170501
*
WRITE '=' DATE-M
WRITE '=' DATE-D
WRITE '=' DATE-Y
*
END

Output:
DATE-M 05
DATE-D  1
DATE-Y  2017

So, you can use it to present dates with leading zeros or other numeric/alphabetic manipulations where you need not lose the leading zeros.