Diagnostic messages when executing the script |
If errors are found in the script code at the time of execution, diagnostic messages are issued to the user.
For example, if there is a call to a variable in the script that has not been previously defined, on the screen a message will be displayed like "name XXXX is not defined".
def MoveObject(_hmap:maptype.HMAP, _hobj:maptype.HOBJ, _parm:ctypes.POINTER(maptype.DOUBLEPOINT)) -> int: if hobj == 0: return 0
In this case (if hobj == 0:) the hobj variable must have an underscore, as in the declaration of the MoveObject function.
if _hobj == 0 return 0
In this case, the if statement must end with a colon.
dofunction = doforeach.DoForEach('Перемещение объектов:', TAC_MED_MOVE)
In this case, the TAC_MED_MOVE identifier is specified without the name of the module in which it is defined:
dofunction = doforeach.DoForEach('Перемещение объектов:', logapi.TAC_MED_MOVE)
When using the tkinter component, diagnostic messages are blocked and the script exits without displaying any messages on the screen. In this case, for debugging, you can call a computational procedure bypassing the dialog with passing some constants instead of the values specified in the dialog. After diagnosing and fixing errors in the script, the call to the tkinter component is restored. For example:
# Move selected objects or one object def MoveObjects(hmap:maptype.HMAP, hobj:maptype.HOBJ) -> float:
MoveObjectsByDxDy(hmap, hobj, 0, 1000) # Временный вызов процедуры для диагностики
root = tkinter.Tk() root.title("Сдвиг объектов") ... def CallMoveObjects(): MoveObjectsByDxDy(hmap, hobj, dx_value.get(), dy_value.get()) root.destroy()
message_button = tkinter.Button(text="Выполнить", command=CallMoveObjects) ...
|