There is nothing wrong with your macro - the problem is only that DockWidth does not currently have a numeric value. It is currently the empty string - when you run the macro, it will become 52, but Keyboard Maestro does not understand that. As soon as it becomes 52, the DockWidth will turn black in your Move & Resize Front Window action. If you click the Try button on the action, it will become 52 and then the DockWidth will turn black.
I changed version 7 so that instead of red, it displays orange where the calculation could be correct if the variable had a different value (I also added a SCREENVISIBLE function that takes in to account the menu and dock).
Depending on the situation, I would like to change the variable whichScreen to Main or Internal, and so would like to use the variable in "Move and Resize" action. Thank you.
When you use a calculation in the parameter, the calculation is a numeric result, and so the variable whichScreen must have a numeric value, not one of the keywords.
“Main” is the same as screen 0, so just set whichScreen to 0.