Building custom ExtendSim blocks and equations.

Code Reference GuideCode Reference Guide
A must have for all new programmers! Commonly used if/else statements, functions, database functions, and more all included on this quick reference sheet.Download
Name Variables in Such a Way that it Means Something
Take the time to carefully consider the names you give variables when writing code. If you don’t name it appropriately, it could cause you a bit of confusion later. You may forget the code, or even worse, it could lead to misinterpretation of what you originally intended.
Use Comments
Comments can be added to the Equation block or custom block by using "//" at the beginning of a comment. The compiler will not read anything on the line past the "//". This will help eliminate any confusion later if you forget the code.
Use Error Traps
If you don't expect a variable should ever have a specific value, test for that condition with an if statement and report an error when it occurs. For example, maybe you know that A – B should always be positive, so you add a test to detect if A – B is ever negative. There are many cases where you need to monitor for errors but it shouldn't consume any of your current attention. Use an error trap and report errors using an error log or error message. If you don't, you will probably miss them, unfortunately.
Document Your Code Before You Write the Code
When you have complex logic to write in code, it is helpful to document what you want the code to do and even document how to accomplish that task before attempting to write the code.