From 5f477ca4a7ccfdd2c26d7e576a4b4a372433fbca Mon Sep 17 00:00:00 2001 From: Ben Agricola <717328+benagricola@users.noreply.github.com> Date: Tue, 17 Dec 2024 10:02:42 +0000 Subject: [PATCH] Check for null tool before tool comparisons (#182) Signed-off-by: Ben Agricola --- macro/machine/M4000.g | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/macro/machine/M4000.g b/macro/machine/M4000.g index 23fbf52..e2dcc02 100644 --- a/macro/machine/M4000.g +++ b/macro/machine/M4000.g @@ -23,17 +23,18 @@ if { param.P >= limits.tools || param.P < 0 } ; This allows us to re-run a file that defines the tool that is currently ; loaded, without unloading the tool. ; This has to be split over multiple lines due to length of the condition. -var toolSame = { global.mosTT[param.P][0] == param.R && tools[param.P].spindle == ((exists(param.I)) ? param.I : global.mosSID) } +if { global.mosTT[param.P] != null && tools[param.P] != null } + var toolSame = { global.mosTT[param.P][0] == param.R && tools[param.P].spindle == ((exists(param.I)) ? param.I : global.mosSID) } -set var.toolSame = { var.toolSame && tools[param.P].name == param.S } + set var.toolSame = { var.toolSame && tools[param.P].name == param.S } -if { exists(param.X) } - set var.toolSame = { var.toolSame && global.mosTT[param.P][1][0] == param.X } -if { exists(param.Y) } - set var.toolSame = { var.toolSame && global.mosTT[param.P][1][1] == param.Y } + if { exists(param.X) } + set var.toolSame = { var.toolSame && global.mosTT[param.P][1][0] == param.X } + if { exists(param.Y) } + set var.toolSame = { var.toolSame && global.mosTT[param.P][1][1] == param.Y } -if { var.toolSame } - M99 + if { var.toolSame } + M99 ; Define RRF tool against spindle. ; Allow spindle ID to be overridden where necessary using I parameter.