A bug or a feature?

I was quite busy this morning and did not look at the Forum for several hours. About ten minutes ago I took a break and looked at recent postings, including the thread re “casting” an A9 to N7.2.

I decided to play a bit. As a starting point I keyed in the following program which I intended as a skeleton for future playing.

DEFINE DATA LOCAL
1 #A (A9) INIT <12345>
1 #N (N7.2)
END-DEFINE
*
IF #A IS (N7.2)
COMPUTE #N = VAL (#A)
ELSE
WRITE ‘no’
*
WRITE ‘=’ #A ‘=’ #N
END

Note the typo in the INIT clause for #A; I forgot the apostrophes. I ran the program. The program ran (at least on my PC, haven’t tried the mainframe yet). The output was:

#A 12345 #N 12345.00

Yes, I should have noticed that #A did not have a decimal point. But I was “on a roll”, so I changed the INIT of #A to 12345.67 (still no apostrophes). Now I got an error message (NAT0094) which surprised me. Finally, I noticed the absence of the apostrophes.

Adding the apostrophes yields the same result for #N, while #A has the expected decimal point.

I played a bit further. If #A has any integer string, or, an integer string followed by a decimal point, Natural accepts the INIT value. If you add an integer after the decimal point, Natural objects.

Also, any “mixed value” like ABC123 gets an error message.

Perhaps someone could confirm this on the mainframe. Then perhaps Software AG could comment on whether this is a bug (my guess) or a feature.

steve

On the mainframe, things are even stranger than on the PC.

For example; INIT <12345> does indeed run (compiler error on PC),
but it ignores the decimal point. Thus #N becomes 1234567.00.

Negative numbers do really strange things (haven’t tried this on the PC yet).

A quick summary:

The PC and mainframe behave differently.

Integer constants are accepted as INITs for an alpha field.

Which, the more I think about it, is not so strange. After all, I can MOVE #N to #A
so why should I not be able to INIT #A to a number?

steve

Whoops; typo in my last posting.

I said: For example; INIT <12345>

I should have said: For example; INIT <12345>

steve

Hard to believe, but I did it again. INIT <12345>
is the proper value

steve

Okay, this is getting silly. I have been typing it correctly all along. The Forum software is changing it. I will try it with extra spaces:

INIT <12345>

in text; integers 1 to 5 followed by a decimal point, followed by 67

steve