4 Buttons open a popup page with submenus.
The popup pages are set to close when the base screen switches, which all of the other buttons on the bar do.
In the popup screens a copy of the button which opens the screen is placed at the exact same position which is set to close the popup screen, so it looks like the button toggles the popup screen.
But I also want to popup pages to close when another popup screen is opened (another one of the 3 buttons pressed) so you can cycle the 4 menus.

I use the following macro code in the all 4 popup screen properties set to run "when loading a screen".
CODE
'When opening this popup screen, detect if there is already a popup screen opened
'besides this screen, so which is not equal to this screen.
$W110=BIN($W1);
'convert $W1 (system memory 1st popup screen number) to decimal
$W111=BIN($W4);
'convert $W4 (system memory 2nd popup screen number) to decimal
IF ($W111 <> 10);
'if the 2nd popup screen is not this screen
CLOSEPOPW($W111);
'close the 2nd popup screen
ELSEIF ($W110 <> 10);
'if the 2nd popup screen is this screen and the 1st popup screen is not this screen
CLOSEPOPW($W110);
'close the 1st popup screen
ENDIF;
I use the $W1 and $W4 system memory values which are the 1st and 2nd opened popup screen numbers.
Each of the 4 buttons runs the same macro, only the screen numbers which are compared differ, the number is that of the popup screen the macro belongs to.
Now in test mode it works fine, I can cycle the 4 screens by pressing the 4 buttons one by one, and only the last opened popup screen is open, the previous one is closed.
But when I download the project to my NS terminal, it doesn't consequently close the popup screen when another one is opened. Sometimes I can open 2 or 3 popup screens and the previously opened screens don't close.
I monitor the $W1 and $W4 words and they reflect the right screen numbers.
Anyone knows why it doesn't work in the hardware ? I am no coding guru so I am always doing trial and error when it comes to this but as it works in test mode I don't know where to look for the problem.
Perhaps the execution time difference between test mode and NS ?
Are there any other ways to accomplish what I want ?
