The following lisp unloads our custom menu, deletes the mnr, mnt & mnc files, and then reloads the menu, we use this as a contractor here has his own version of 2004 and uses our menus.
It workes fine, but a recent server crash has shown a small problem with the way this code works, it ran as normal while the server was down, but couldn't re-load the menus, next time it ran it couldn't find the menu to unload and posts error messages saying menu not found, and it takes about 5 clicks to clear it each time, this happens till the menu is physically re-loaded.
What lisp commands do I have to look at to see if the menu is loaded, and if it isn't, automatically load it?
This would also help on computer setup, all that would be required is that the folder containing this acaddoc.lsp file, would have to be added to the support path and it would auto load the menus.
Cheers in advance for any help.
(vl-load-com)
(if (findfile "X:/AIDS/BLOCKS/RYBKA_BLOCKS/MENU/RYBKA.mnr")
(vl-file-delete (findfile "X:/AIDS/BLOCKS/RYBKA_BLOCKS/MENU/RYBKA.mnr"))
)
(if (findfile "X:/AIDS/BLOCKS/RYBKA_BLOCKS/MENU/RYBKA.mnt")
(vl-file-delete (findfile "X:/AIDS/BLOCKS/RYBKA_BLOCKS/MENU/RYBKA.mnt"))
)
(if (findfile "X:/AIDS/BLOCKS/RYBKA_BLOCKS/MENU/RYBKA.mnc")
(vl-file-delete (findfile "X:/AIDS/BLOCKS/RYBKA_BLOCKS/MENU/RYBKA.mnc"))
)
;set the flag
(setq flag1 T)
;check if the menu is already loaded
(setq loaded (menugroup "RYBKA"))
;if it is not loaded
(if (= loaded nil)
;do the following
(progn
;find the menu file
(setq temp (findfile "X:/Aids/Blocks/Rybka_Blocks/Menu/RYBKA.MNS"))
;if you find the menu
(if temp
;do the following
(progn
;switch off dialogues
(setvar "FILEDIA" 0)
;load the menu
(command "menuload" "RYBKA")
;switch on dialogues
(setvar "FILEDIA" 1)
;install the pulldown
(menucmd "Gacad.help=+RYBKA.RYBKA")
;inform the user
(prompt "\nLoading RYBKA Menu....")
) ;progn
;menu not found, so do the following
(progn
;inform the user
(alert "Cannot Locate RYBKA Menu. \nRe-Run Install.")
;clear the flag
(setq flag1 nil)
) ;progn
) ;if
) ;progn
(progn
;Menu previously loaded so lets unload it now
;unload the menu
(command "menuunload" "RYBKA")
;find the menu file
(setq temp (findfile "X:/Aids/Blocks/Rybka_Blocks/Menu/RYBKA.MNS"))
;if you find the menu
(if temp
;do the following
(progn
;switch off dialogues
(setvar "FILEDIA" 0)
;load the menu
(command "menuload" "X:/Aids/Blocks/Rybka_Blocks/Menu/RYBKA.MNS")
;switch on dialogues
(setvar "FILEDIA" 1)
;install the pulldown
(menucmd "Gacad.help=+RYBKA.RYBKA")
;inform the user
(prompt "\nLoading Users blocks Menu....")
) ;progn
;menu not found, so do the following
(progn
;inform the user
(alert
"Cannot Locate RYBKA Menu.
\nRe-Run Install."
)
;clear the flag
(setq flag1 nil)
) ;progn
) ;if found
) ;progn
) ;if loaded