====== Break points ====== It is possible to go step-by-step when debugging, and watch the changes of variables in the program. ===== ST ===== A breakpoint may be inserted in two ways: a mouse click left from the line number in the program, or right click and "Breakpoints - Insert breakpoint" in the context menu. {{:en:mervis-ide:35-help:breakpoint6.png}} Inserted breakpoints are recorded in the "Breakpoints" tab. {{:en:mervis-ide:35-help:breakpoint7.png}} If a program is stopped at a particular breakpoint, in the "System status" tab the breakpoint is visible. {{:en:mervis-ide:35-help:breakpoint8.png}} In the program, the current position of the stopped program is marked by a yellow arrow. {{:en:mervis-ide:35-help:breakpoint9.png}} ===== Breakpoint in FUPLA ===== In FUPLA, the breakpoint is similar to the ST editor. Right click and select "Breakpoints - Insert breakpoint" in the context menu or select a block and use the F9 key to toggle breakpoint. {{:en:mervis-ide:35-help:breakpoint11.png}} The indication is similar to that in the ST. In the program, the current position of the stopped program is marked by a yellow arrow. In the lower right corner of the block there is a number which specifies the order of the steps. {{:en:mervis-ide:35-help:breakpoint10.png}} ===== Breakpoint step by step ===== {{:en:mervis-ide:35-help:breakpoint.png}} {{:en:mervis-ide:35-help:breakpoint1.png}} **Continue** **[F5]** - Program continues to another breakpoint. {{:en:mervis-ide:35-help:breakpoint2.png}} **Step over** **[F10]** - Program goes to the next command (not necessarilly to a breakpoint). {{:en:mervis-ide:35-help:breakpoint3.png}} **Step into** **[F11]** - Program goes to the next command or enters a function / method from current command (marked by an arrow, if it is a single command in the line). {{:en:mervis-ide:35-help:breakpoint4.png}} **Step out** **[Shift+F11]** - Program jumps out from a function / method to the point from which the function / method was called.\\ {{:en:mervis-ide:35-help:breakpoint5.png}} **Break** **[Ctrl+Alt+Pause]** - Program stops at the current position, from this position the program can be debugged step by step. ==== Example of stepwise program execution in ST ==== An example how to go step-by-step and follow the changes of variables and execution of a function which calculates fourth power of a number. When the debug is started, the program interrupts the execution at the first breakpoint. {{:en:mervis-ide:35-help:breakpoint20.png}} Press **Continue [F5]** to jump to the next breakpoint at line 9. {{:en:mervis-ide:35-help:breakpoint21.png}} If no breakpoint is inserted but we want to follow the program state even if the function is running, we have to use the **Step into** button **[F11]**. {{:en:mervis-ide:35-help:breakpoint23.png}} In the called function, go further using **Step over [F10]** and **Step into [F11]** buttons. {{:en:mervis-ide:35-help:breakpoint24.png}} The called function is exited only after all lines of the function code are executed, or by pressing the **Step out [Shift+F11]** button, which jumps to the point where the function was called, or **Continue [F5]**, which jumps the program to a next breakpoint. {{:en:mervis-ide:35-help:breakpoint25.png}} By going step by step, the program goes from the last breakpoint again to the first breakpoint. {{:en:mervis-ide:35-help:breakpoint26.png}} ==== Example of step-by-step debugging in FUPLA ==== Example to show how to go step-by-step in a function for adding, subtracting and multiplication. When the step-by-step debugging is started, the program stops at the first breakpoint. {{:en:mervis-ide:35-help:breakpoint30.png}} The next breakpoint is reached by the **Continue [F5]** button. {{:en:mervis-ide:35-help:breakpoint31.png}} Using **Step over [F10]** and **Step into [F11]**, we may go as deep as to the internal code of the function. The code is left by the **Step out [Shift+F11]** button. {{:en:mervis-ide:35-help:breakpoint32.png}}