Hi all, I have a problem with this Natural code:

Hi all, I have a problem with this Natural code:

0010 DEFINE DATA LOCAL
0030 1 TAB (/LIM)
0040 2 ALFA (A10)
0050 2 NUM (N3)
0060 END-DEFINE
0070 INPUT ALFA() NUM()
0080 WRITE ALFA() NUM()
0090 END

In Natural V Unis Solaris 6.2.3, checks and uses occurrence one when I RUN it.
Of course declaring LIM as a constant the problem is solved but it took me a while to locate the error.
The same program on Windows XP V 6.3.5 PL0 Natural Studio (Rev.: 16 532) does not check.
I’d appreciate any help.
Best Regards
Teo Sibelo

Hello Teodoro,

Your code is not compilable on Nat 6.3.9PL0@Solaris.

DEFINE DATA LOCAL
1 TAB (/LIM)   /* <-- NAT0280 Index entry incorrectly specified for field.
2 ALFA (A10)
2 NUM (N3)
END-DEFINE
INPUT ALFA(*) NUM(*)
WRITE ALFA(*) NUM(*)
END

That’s strange :shock:

Matthias

You can replace LIM with a literal or a named constant.

DEFINE DATA LOCAL  
1 LIM (I4)  CONST <1>   /* named constant
1 TAB (/LIM) 
2 ALFA (A10)  
2 NUM (N3)  
END-DEFINE  
INPUT ALFA(*) NUM(*)  
WRITE ALFA(*) NUM(*)  
END 

I got an old NAT6.1@WinXP. Your code is running there. :!:

Here’s my try:

DEFINE DATA LOCAL
1 TAB (/LIM)
2 ALFA (A10) init <'X'>
END-DEFINE
display *OCC(tab.alfa) *LBOUND(tab.alfa) *UBOUND(tab.alfa)
WRITE '=' ALFA(*)
display *OCC(tab.alfa) *LBOUND(tab.alfa) *UBOUND(tab.alfa)
END

output:

Page    1

    OCC       LBOUND      UBOUND
----------- ----------- -----------

          0           1           0
ALFA: X
          0           1           0

That’s odd.

So I tell you an old programmer’s wisdom: This is a compiler bug.
… and I think it was also on Windows and fixed between NAT6.2 and NAT6.3

Regards

Matthias

Thanks Matthias for your quick and accurate response.

Here at home I got Nat6.2@Win2k. The bug is still there.

So I think an Upgrade to 6.3 will fix this on solaris, too.