0010 DEFINE DATA LOCAL
0020 1 FOR (N3)
0030 1 REDEFINE FOR
0040 2 EDITED (N3)
0050 1 TO (N3) CONST<1>
0060 1 STEP (N3) CONST<2>
0070 END-DEFINE
0080 *
0090 FOR FOR EQ TO TO STEP STEP TO
0100 WRITE EDITED (EM=-ZZ9) TO STEP
0110 END-FOR
0120 END
That was strangely fun. Glad I didnāt notice Brian beat me to the answer else I probably wouldnāt have worked at figuring it out. I failed to look at the spaces between columns. I think Brianās N3s are more accurate than my I4s would have been, though Brianās output seems to suggest his runtime results were not using the N3. I found the same struct problem on v6.3.12 on HP UX .
DEFINE DATA LOCAL
1 TO (I4) INIT <1>
1 STEP (I4) INIT <2>
1 FOR (I4)
1 REDEFINE FOR
2 EDITED (I4)
END-DEFINE
Obviously you can gain even more obfuscation using struct
How about this one:
define data local
01 for (I1)
01 redefine for
02 edited(I1)
01 to (I1) init <1>
01 step(I1) init <2>
end-define
for
for eq to to step step to write edited (EM=-ZZ9) to step
end-for
end
This is why KCHECK=ON should be the default setting in NatParms. Of course you still would have to look for overrides (during code walkthroughs) to stop programmers from cheating.
OPTIONS KCHECK=OFF
DEFINE DATA LOCAL
1 FOR (I1) 1 REDEFINE FOR
2 EDITED (I1)
1 TO (I1) INIT <1>
1 STEP (I1) INIT <2>
END-DEFINE
FOR
FOR EQ TO TO STEP STEP TO WRITE EDITED (EM=-ZZ9) TO STEP
END-FOR
END
Hi Matthias,
I suspect that after your post (and upgrading to the latest Natural release you will read something like this from the Natural documentation:
āHere is a list of keywords in the Natural programming language. You cannot use any of the following as identifiers in your programs: ā¦ā
The weird thing is that the compiler Nat 4.2.6 on zOS at least will catch some things but not others. Your example stowed fine for me - I even called the program PROGRAM - and this example also works
DEFINE DATA LOCAL
1 EQ (A2)
1 THEN (A2) INIT <'IF'>
END-DEFINE
INPUT EQ
IF THEN EQ EQ
WRITE '='
END-IF
END
but each part of this one fails - as you cannot INPUT INPUT or WRITE WRITE let alone IF IF
Sorry, this is āthe serious partā which Iāve missed in my previous message.
Well, it is still optional ((KCHECK) Keyword checking ā¦ OFF) āfeatureā of our Natural 8.2.2.3. If it were within my power, I think Iād rather removed this altogether - what`s the reason to keep it āoptionalā? The good program should be simple and clear
I understand the need for having options because there could be issues if existing code breaks. I would tighten enforcement up in development but leave it open in production until I was sure the bad code was fixed.
Weāre on Natural 4.2.7 so this is something I will need to handle the next upgrade.
Every programming language has strange syntax and naming conventions. Personally, I think reserved words should never be permitted as variable names. However, as Brian noted, this could cause problems when new reserved words might be added to the language and existing programs suddenly fail.
Here is one of my favorite Natural Syntax anomalies: (use SAGās employees demo file)
DEFINE DATA LOCAL
1 MYVIEW VIEW OF EMPLOYEES
2 NAME
2 FIRST-NAME
2 CITY
2 COUNTRY
END-DEFINE
*
READ MYVIEW BY NAME FIRST-NAME CITY
DISPLAY COUNTER NAME FIRST-NAME CITY
END-READ
*
** WRITE TNAME NAME FIRST-NAME CITY / T*CITY āLOOK AT THE VALUE OF CITYā
*
END
Questions:
Will this program Check?
Will it Run?
If it runs, what will it be doing?
If it runs, explain the output.
If it runs, why does the output end where it does?
If stuck on last question, uncomment the WRITE statement and re-run.
I would expect the following: Display all Employees with empty NAME since the fields in the from-to-clause (i.e. first-name and city) are empty at the beginning.
We got no employees file at our test systemā¦ Let me see what I can do.
Answers 1) and 2) are, of course correct. That was the real objective of the example, to point out that the words āstarting fromā and ātoā are unnecessary. This can be very confusing. Some people look at the statement and think that they can read logical by three fields.
However, you really need a file to properly answer the rest of the questions. There are no records with blank names; but, there is quite a bit of output.
Do you have an old Personnel file around?
Or do you have Natural on the PC, which has the same employees file?