Now that we have seen how to control the flow of your application, let’s see how you can break your code into reusable blocks.
12. We can call this function from within our DoTask Procedure with the Get function.
13. Click RUN (F5) to execute the program.
14. You should now see the info box pop-up saying: task: 20. This is because our defined value was 4 and we multiplied it by 5. The same goes for “something else”, 12*5= 60.
15. We can go through the program step by step, by using the breakpoints. Click next to a line of code to make one.
16. In case of a procedure you can choose to step into the procedure by clicking STEP INTO (F11) on the top.
17. By clicking STEP OVER (F10) you can step over the procedure.
18. Note: On the right side you will find the call stack. The call stack is a panel in the debugger. It shows different procedures and functions that have been calling each other. If you double click on an item in the list, the cursor will jump to that specific line in the code.
19. Let’s extend the example and add another procedure.
20. And again we will be calling this procedure from within the DoTask procedure.
21. Place a breakpoint at the line of code you just created at line 15 and click on RUN (F5), you now step into the procedure. In the locals panel you can see what is being generated at each step.
22. Note: Within DataFlex, by default, variables are passed by value. You can also pass variables by reverence, you just need to define it in the procedure.
23. Change sdescription into an expression
24. Click RUN (F5)
25. Now you see that sDescription has changed.
26. NOTE: you can use this system or two reasons, the first would be if you make use of big chunks of data, the second is to return multiple values from a single function.
27. Another example can be loaded in using the workspace explorer.
28. Workspace explorer > current project > MoreFunctionsAndProcedures
29. Place a breakpoint and click RUN (F5), go step by step through the program with STEP OVER (F10) and explore the code.