Introduction to scripting
A script is a short piece of computer code that is used to perform a calculation. Below is some code that calculates the length of a vector. Try changing the values of the components of the vector and press 'execute'. The results of the calculation should appear in the 'Script Output' box.
Many problems that can be solved by scripts can also be solved with a pocket calculator or with a spreadsheet program like Excel. However, scripts can be structured to be easier to read than the other alternatives. Scripts can be written in many programming languages such as python, Matlab, or Mathematica.
The code is interpreted line-by-line because this makes it easier to debug. This might be confusing if you are familiar with programming structures such as function definitions, conditional statements, or loops which often extend over several lines. Any programming structure that extends over several lines will not be interpreted properly but this should not be a problem because we won't be using advanced structures. The application remembers all of the variables that have been defined since the session was started so if you want to start a new problem, it is a good idea to close the tab and start and new session.