Instead of
var := var + const you can write var += const;
var := var - const you can write var -= const;
var := var * const you can write var *= const;
var := var / const you can write var /= const;
(source: This tip was posted by jkiss to
www.navision.net)
Marcus Fabian
m.fabian@thenet.ch
+41 79 439 78 72
Comments
but the guidelines say no.
it's more difficult to read the code if you don't use the guidelines
It's a matter of personal style I guess. If you like it, use it. If you don't, don't.
RIS Plus, LLC
Well if you are the only one that will ever have to read the codem then this is maybe OK, but when (an mostly is so) more thn one person have to dela with the code and over a longer period of time, then this is not good.
bostjnl
I used the following
Repeat
[various code statements]
NextDate := 1;
Until NextDate >= Today;
It went into an infinite loop.
When I changed the code to
NextDate := NextDate + 1;
everything worked well.
Apparently, the += assignment doesn't always work.
Anybody that accesses code should know what the code means. If they don't understand the code, they should just stay away from it.
RIS Plus, LLC
BUT, try the following code and you will see that there's some difference between the 2 syntaxes:
Variables:
Name DataType Subtype Length
nextdate Date
w Dialog
The code:
//++
nextdate := CALCDATE('-9999D', TODAY);
w.OPEN('#1#########', nextdate);
REPEAT
w.UPDATE(1, nextdate);
nextdate += 1;
UNTIL nextdate >= TODAY;
w.CLOSE;
MESSAGE(FORMAT(nextdate));
nextdate := CALCDATE('-9999D', TODAY);
w.OPEN('#1#########', nextdate);
REPEAT
w.UPDATE(1, nextdate);
nextdate := nextdate + 1;
UNTIL nextdate >= TODAY;
w.CLOSE;
MESSAGE(FORMAT(nextdate));
//--
Brg,
János Borsics
--
János Borsics
It doesn't works.
This syntax came from C-Code and everyone who can read C should be able to read this.
By the way:
It is also possible to comment out a large code block by typing { and } but this is still not allowed (see CALguide).
is equal to
Microsoft Dynamics NAV Developer since 1997
MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
Thats fine, but what if you don't come from a 'C' or 'C' related background? I came from a Cognos(Powerhouse) backgound, you only have the guidelines to go by. The C/AL guidlines on the 3.70 disc still recomend the a := a + 1; approach, but I couldn't see anywhere, that you cannot use the 'C' notation.
I think, Navision preferes the normal syntax, so they will never add this to the guidelines.
Microsoft Dynamics NAV Developer since 1997
MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
I think, C/SIDE is based on Pascal, so there should be no other things from other programming languages.
It seems that on of the programmers in Denmark integrated this little feature (Easter egg) although it's against Navisions (C/AL) protocol.
Changes could be they will delete this functionality in the future, this would mean everything you program using this kind of assignments stops working after an upgrade...
This would be a bit unlikely
btw, I think it's doesn't read the good, especially if you don’t expect it to be in the code.
If it was hard to write, it should be hard to understand."
They tried something like this in the past with the comment syntax: In Version 3.00 (Navision Solutions Beta), the "{" and "}" was ignored by the compiler and the code inside this was executed.
But many many individual solutions uses { and }, so that this will supported also Navision Denmark doesn't like it.
So, I think, they will not remove the support for the +=, *=, ...
But let us see what the .net version will bring to us :roll:
Microsoft Dynamics NAV Developer since 1997
MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
Guido
If it was hard to write, it should be hard to understand."
You'll have to forgive me, i'm new to this game. I can program a little in C++ and that's about it.
The company that I work for doesn't have anybody that can program or write reports properly and they would like me to do it. I can do it. However I have been trying to find a complete list of all of the C/AL functions and commands etc, but I can't find any sort of literature anywhere.
I've read the C/AL programming course notes and they're really elementary and provide nothing extremely useful.
If anybody has any suggestions then I would be grateful
Have you tried the:
- CAL Programming Guide.pdf (provided to partners)
- Introduction to CAL Programming.pdf (provided to partners)
- or the w1w1adg.pdf (Application Designer's Guide) located in the product CD and easy to find.
Arhontis
https://forum.mibuso.com/search
MBS-Navision 4.00 Quick Reference:
http://www.mibuso.com/dlinfo.asp?FileID=355
MBS-Navision 3.70 Quick Reference:
http://www.mibuso.com/dlinfo.asp?FileID=288
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
If it's like java or C, the reason would be that the process to access a variable is quite slow! ( I += 1 could be done with bitshifting while I = I+1 need to access a var two times )
To say C/AL shouldn't have a feature that is more efficient because some other language doesn't have it makes no sense. The point is, Den Ster is right. If you are a C/AL programmer then deal with it, that's part of reading code, and besides that += is not exactly rocket science. If you are not a C/AL programmer then why are you complaining, you shouldn't be stressing over the code.
I mean really folks, if you can't remember +=,-=,/=, and *= or at least look it up then maybe programming is not the right profession for you. if you want a language to hold your hand go write in VB.
</end rant>
I traded my sanity for a railgun
also if it is more confusing, it's just a matter of time before you get used to it.
In the end of the day a "customer/partner" only wants "the best" and they don't care about how things are programmed and if they can read it back.
The reading back is something for a programmer and the research involved in it.
I just started to do some report design and programming in Navision,
and with my underlying VB/Delphi-knowledge from school I don't have any trouble "reading" the code.
The most important thing if you program is to keep your customer happy and to keep it effficient.
Example:
Search engine (difficult coding) 20% faster - Better for a normal person
Search engine (easy to read coding) - Nice for a beginning student programmer
But in order to get back to topic: Thanks for the nice tip
Bachelor of Business Administration and Information Technology
minor Application Development
" Don't use comma (,) use dot (.) "