Skip to main content

Advanced Development Functions

Program Debugging

When running a process in Laiye RPA, we always hope for a successful result. However, sometimes the expected results are often not achieved, especially for novices. Laiye RPA can either report an error when running, or simply let the program run without results. At this time, you need to debug the program.

Program debugging is the process of correcting grammatical and logical errors by manually or automatically testing the compiled program before it is put into actual operation. It is an essential step to ensure the correctness of computer software programs.

In fact, we have already used the simplest, most common, and most practical method of program debugging before: the "output debugging information" command. Add the output debugging information on the previous or next line of the key code to check whether the parameters and return values are correct. Strictly speaking, this is not a method of program debugging, but it can be used to test and eliminate program errors. It is also an important supplementary method in some cases where debugging is not supported.

This section will introduce the "real sense" program debugging method, which can accurately locate the cause and location of the error based on the error information prompted and the runtime variables monitored.

Principles of Program Debugging

First of all, we must clearly realize that: a program is a means of implementing processes in the human brain to programming tools; program debugging is essentially a way to help clarify the human brain. Therefore, in the process of debugging, the human brain must be clear, so that problems can be quickly and accurately located and resolved.

  1. Calmly analyze and think about the prompt messages related to program errors.

  2. Be open-minded and avoid dead ends. If a method has proved to be unworkable, you need to try another way of thinking.

  3. Avoid aimless temptation, which is to purposefully reduce the scope of the investigation, and ultimately locate the wrong place.

  4. Debugging tools are just auxiliary methods to find the location and cause of the error. Using debugging tools can help you clarify the data flow logic in the program, which can assist thinking, but it cannot replace thinking. When solving actual problems, you still need to make correct judgments after thinking according to the debugging prompts.

  5. Do not just stop at correcting a mistake, but instead think about the essential cause of the mistake. Did you write the wrong name carelessly? Or did you use the wrong command? Or is there a problem with the process design? Only when the essential cause of the error is found can the error be circumvented fundamentally, and similar errors will not be made in the future.

Methods of Program Debugging

First of all, we must be very clear about the business process of the system. Business generates data, and data reflects the business. The operating logic of the program also represents the operating process of the business and data. When an error occurs, you should first think of and know the business processes and data on which this problem occurs.

For example, let's say when you click the "submit" button, an error occurs in the form submission. At this point, you should think about: What data transfer occurred after clicking the "submit" button? Then according to the error message, speculate where the error may have occurred in the process of business data flow, so as to determine the location of the breakpoint we debug.

Laiye RPA Debugging Method

Add and Remove Breakpoints

In the "code view", to add a breakpoint, click to the left of the line number for any line of code. Click this location again to delete this breakpoint.

**Figure 63: Adding and deleting breakpoints**

Commissioning

Click the "debug run" or "debug run full process" menu item in the "run" menu or "run" toolbar to debug the running program. The difference between the commands is that one just debugs and runs a single process block, and the other is debugs and runs the entire process.

**Figure 64: Debug operation menu item**

**Figure 65: Debug run toolbar**

Single Step Debugging

When debugging is running, the program stops at the first breakpoint, and the four common debugging operations are listed in the debugging status bar: continue to run (F6), step over (F7), step into (F8), step out (F9). "Continue to run" means to continue to the next breakpoint; "step over" means to continue to run the next command; "step into" means to continue to run the next command, if the next command is a function, then enter Function, stop at the first command in the function; "step out" means to jump out of the function of this layer and return to the previous layer.

The bottom left of the debugging status bar lists the values of the variables of this process block. When the program runs to the breakpoint, the next step of debugging is performed. At this time, special attention needs to be paid to observe whether the data at each step of the program is processed by the business process. Correct data to judge whether the program is executed correctly. These data include input data, return data, etc. If the program does not enter the breakpoint we set in advance, then it is necessary to re-estimate the location of the error based on the error information and business process flow logic, and reset the breakpoint. In the end, we will continue to refine and dismantle a big problem, and finally locate the wrong point accurately.

**Figure 66: Single-step debugging**

The bottom right of the debugging status bar lists a list of breakpoints in this process block. You can enable, disable, and delete breakpoints as needed.

**Figure 67: Breakpoint list**

Tips for Breaking Points

The general method and location of the break point are:

• Break the program at the first line of the logic program where the error may occur.

• Break the program breakpoint in the line where the error is most likely to occur.

Timeline

Source code version control is a very important engineering method in software development. It can save the historical version of the code and can trace back to the code progress of any time node. Version control is a necessary means to ensure the normal progress of the project. For beginners, it is recommended to start source code version control at the beginning of a small project, which will be of great benefit in future work.

Laiye RPA does not integrate Git, SVN and other third-party source code version control software, but provides Laiye RPA native version control: "timeline". The timeline refers to the version of the code at different points in time.

  1. Save the timeline manually

The "save timeline" button appears on the toolbar's "timeline". Click "save timeline" to save the code. When saving the timeline, you need to fill in the remark information to describe what content of the code was modified at that time.

**Figure 68: Save timeline**

  1. Automatically save the timeline

If the user does not remember to save the timeline, it is not a problem, since Laiye RPA automatically saves the timeline every five minutes. If the user does not modify the code during this time, the timeline will not be saved.

  1. View the timeline

Click the "timeline" button on the toolbar, the "timeline" page lists the saved time points according to "today", "within seven days", and "earlier". Click any time point to view the current file and the difference of the content of the selected point-in-time file will be marked with a red background.

If you want to restore part of the code in the timeline, you can directly click the blue arrow in the code comparison box to directly restore the code to the existing code.

**Figure 69: Timeline comparison code**

  1. On the "timeline" page, click on the details of the note at any time point to view the detailed information of the note at that time point, as shown in the figure:

**Figure 70: View timeline notes**

  1. On the "timeline" page, click the restore button at any time point to restore the code content of the timeline to the existing code. At the restored time point, there will be a green R mark in the upper left corner, indicating Revert, move the mouse to the R mark, it will display the specific time point from which time point to restore.

**Figure 71: Recovery timeline**

Modularity

Modularity Overview

The idea of modularity has long existed in many industries and is not unique to computer science.

For example, the construction industry has long proposed the concept of modular construction, that is, prefabricating various house module components in the factory and then transporting it to the project site to assemble various houses. The modular components are prefabricated in the factory, which facilitates the organization of production, improves efficiency, saves materials, and is less harmful to the environment. The module construction is simple, fast, flexible, clean, and environmentally friendly.

As another example, the functions of modern electronic products are becoming increasingly complex, and the scale is getting increasingly bigger. Using the functional decomposition and combination ideas of modular design, you can choose modular components (such as integrated circuit modules) and use their standardized interfaces to build a complex functional electronic system. Modular designs can speed up the development cycle, and the modular components tested have greatly improved the reliability of the electronic system. The standardized and universal components make the system easy to build and maintain.

In short, the idea of modularization is to decompose the product into several functional modules on the basis of functional analysis of the product.

The blocks are then assembled to form the final product.

Modularity of Laiye RPA

Modular programming is a software design technology, which breaks the software into several independent, replaceable modules with predetermined functions. Each module realizes a function, and the modules are combined through an interface (input and output part) to form the final procedure.

Almost all high-level programming languages support modular programming, but the supporting technologies and terms, such as subprograms, procedures, functions, modules, and packages, may vary. We will collectively refer to these as "functions" below.

Function construction generally involves the following:

• Function call and return: call is to request the execution of the function, and the control should be returned to the caller after the function is executed.

• Parameters: equivalent to the input data required by the function. Generally, you need to declare the parameters in advance, and provide specific parameter values when calling.

• Return value: equivalent to the output data of the function.

The prefabricated parts in Laiye RPA are a typical example of modular programming. Laiye RPA currently has provided more than 300 prefabricated parts, covering the operation of mouse and keyboard, various interface elements, automated operations of common software, data processing, file processing, and all aspects of network and system operations. These prefabricated parts are modular and relatively independent, but can be combined to complete complex functions.

In addition to the prefabricated parts in Laiye RPA, users need to pay attention to the rational arrangement of processes and process blocks when writing their own processes and process blocks, as this is also an important application of modularization. As mentioned earlier, Laiye RPA does not specify how detailed a process block should be. A process block can have many commands, or just have one command. When all business processes are put in one process block, if the business process is not complicated, it works out. However, when the business process is more complicated, there can be many disadvantages: large chunks of code, unclear logic, inconvenient debugging, and difficulties in judging emerging problems. Therefore, for business processes, we strongly recommend putting relatively independent business processes together into independent process blocks, and complete complex business processes through data transfer and cooperation between process blocks.

In addition, you can also extract some common functions into independent process blocks and make it a plug-in for others to call. We will discuss extension plug-ins in the next chapter.