I am using Natural Version 6.3.12 and am trying to manipulate Natural source code within the Natural Source Work Area.
I am using user exit USR1057N within a Natural program to read an existing Natural program into an array.
Scan replace is then being used to update the contents of the returned program array.
The updated source code is then being written to the Source Work Area using a write(1) which has been defined as DEFINE PRINTER(1) OUTPUT ‘SOURCE’.
The code within the Source Work Area is then attempted to be run but is returning Natural error NAT0399.
The object has an include code line which seems to not have a line break and is merging with the following line;
INCLUDE COPY1
RESET #FIELD1
In the above example the ‘RESET’ line returns the NAT0399 error.
If I manually edit the Natural Source Area to comment out the ‘INCLUDE’ code line I am able to ‘cat’ the source. If I then reinstate the commented ‘INCLUDE’ code line, I am now able to ‘cat’ the source code.
This seems to be a line break issue which is resolved on manual edit.
Additionally the source code I am writing to the Source Work Area has multiple ‘INCLUDE’ codes within. If I comment out the first ‘INCLUDE’ code instance on generation the error moves to the next ‘INCLUDE’ code within the generated source code.
Hello Albert
I once crafted a subsystem similar to what you are doing but it did not contain any INCLUDE commands as my faint memory suggests.
Without knowing the complete text of error 0399 I can suggest you try the following:
determine the end of line character(s) for your system and insert those hex character(s) after each of your INCLUDE statements when you write to the source output.
insert at least one comment line after each INCLUDE
I have previously tried inserting a h’00’ at character 72 of each ‘INCLUDE’ lines and ensuring that there is a comment line prior to and after each ‘INCLUDE’ line without success.
If I manually edit the Natural Source Area and comment out the ‘Copy’ code line I am then able to ‘cat’ the source. It is then possible to uncomment the ‘Copy’ code line at which point I can now ‘cat’ the source.
The following snippet of source code from program ADPROG2 uses user exit USR1057N to read program ADPROG1 and then write the source to the Natural Source Area and to then run it.
It’s a simple fix. Change all your printer references from (0) to (1).
It was so long ago that I don’t remember whether I stumbled upon it or found the answer somewhere in the documentation, but I do now remember fighting with this issue. You can write source to printers 1-31, but not to 0.