During this period, we have been maintaining the "Total Station Distance Accuracy Test" software compiled by VB6. Because two baselines are added to the new requirements, and the prism spacing of each baseline is not the same, therefore, I used a Boolean global variable and designed to assign a value to the global variable in the event of clicking a button. Here I did not consider the issue of global variable initialization, of course, the initialization of this variable has no effect on the program itself.
However, I did not have the sensitivity to global variable initialization, which led to problems later. The reason is that I hope the software can do better, this prevents data errors once the baseline is blocked. Therefore, I add a global variable to store the value of each ranging task, I compared the ranging value with the global variable (the last ranging to) and analyzed the gap between the two values to determine whether the data is valid automatically. After the software is modified, after testing, it solved the problem of data errors caused by blocking. However, when I repeatedly used the software, the data could not be displayed, the program has been stuck, and I don't know why. I have reproduced the problem several times and suddenly realized the problem of global variables. Before using global variables, initialize it, compile and run it, and solve the problem. This reminds me of the previous R & D department meeting. The boss said that in the future, the coding rules of our software must follow a "global variables must be initialized before use !"
Here, I will summarize again -- the global variables must be initialized before use!