Hello, I am completely new to Natural and have been poring over as much documentation and code examples as I can to get a better understanding of syntax.
I keep seeing multiple examples of the operator “:=” and am wondering about what exactly this means as opposed to a single “=”? From what I can tell, I just assumed it is shorthand for assignment as opposed to writing out COMPUTE or something else wordy.
The “becomes” operator ( := ) was introduced as shorthand for the “ASSIGN =” syntax, ASSIGN being a synonym of COMPUTE. Then, at the user community’s request, “becomes” was allowed in combination with a keyword. Now, all five variations are legal:
Well, I think keyword options are a bit off-topic, but now that you have mentioned them, …
It was a bit of a surprise to me, but your example ran and produced the correct result under Natural for Windows 9.1.1.
DEFINE DATA LOCAL
1 #N2(N5.2)
1 #N5(N5.5) INIT <123.98765>
END-DEFINE
ROUNDED #N2 := #N5
DISPLAY #N5 #N2
END
Page 1 09/12/19 11:42:31
#N5 #N2
------------ ---------
123.98765 123.99
My personal preference is to always use keywords. I find it easier to skim down the left side of the code to see what’s going on. Random characters (that is, variable names) slow that process.