Skip to Main Content
Due to the recent acquisition by IBM, the Adabas & Natural Ideas Portal does not contain ideas from products ApplinX and EntireX any longer. Please refer to the IBM Ideas Portal for these products from now on (IBMid required). Existing content will be migrated during the next few weeks.
Status Not in Plan
Categories Natural (NAT)
Created by Guest
Created on Jul 15, 2021

Prevent NAT1326 with MOVE...TO SUBSTRING with DYNAMIC variables

PROBLEM:
=======
The following program will get a Runtime error NAT1326:

* see Software AG Support Incident 113138 ...
DEFINE DATA LOCAL
1 #A (A) DYNAMIC
1 #COL (I2) INIT <1> (EM=ZZ9)
1 #I (I2) (EM=ZZ9)
END-DEFINE
*
EXPAND DYNAMIC VARIABLE #A TO 500
*
FOR #I = 1 TO 20
* MOVE 'ABC' TO SUBSTRING(#A,#COL,5) /* 5 is OK
MOVE 'ABC' TO SUBSTRING(#A,#COL,4) /* but 4 gets error NAT1326 when #I=2
*
PRINT (AD=IL SG=OFF ZP=ON)
#I
'=' #COL (CD=YE)
'=' *LENGTH(#A) (CD=RE)
#A (AD=D CD=GR)
*
#COL := #COL + 5
END-FOR
*
END
.
EXPLANATION (from R&D):
===========
The second iteration of the FOR loop would extend the dynamic variable and fill positions 6-9 with 'ABC' but it would create a "gap" of uninitialized memory at position 5.
The "uninitialized gap" is the reason for the NAT1326.
.
CHANGE ENHANCEMENT REQUEST:
==========================
Q. Could you enhance the behaviour of the statement "MOVE...TO SUBSTRING" for DYNAMIC variables, so that Natural will "automatically" initialize any "gap positions" with blanks, please? - thanks
.
REASON:
======
The current behaviour is unintuitive.
This change enhancement would make Natural's behaviour more intuitive and useful for the programmer.
And after all, isn't that what Natural is supposed to do?

Created on Brainstorm 12/14/2016 05:49 PM
Brainstorm ID 4380
  • Admin
    Eli Cohen
    Reply
    |
    May 4, 2023

    The Expand command does not initiate the field with a value, it is allocating memory space.

    In order to achieve this you could use this command:

    MOVE ALL ' ' TO #A UNTIL 500

    And no error will occur.

  • +5