Re: bbs.menu vs bbs.menu_exists
By: Digital Man to nolageek on Mon Jan 13 2020 02:26 pm
bbs.menu_exists() with a sub-directory specified should work fine. See xtrn_sec.js as an example which check for the existence (and displays) text/menu/xtrn/*.*.
I can't figure out why this code doesn't work then:
function mystMenu(file) {
// check for 'file' in current command shell menu dir and if not found use
// 'mystique' menu directory
if (bbs.menu_exists(user.command_shell + '/' + file)) {
bbs.menu(user.command_shell + '/' + file);
} else {
bbs.menu('mystique/' + file);
}
}
If I then use mystMenu('mainmenu'); in my shell, it always shows the menu from the mystique directoy - even though they exist in both.
I've tried combinations of testing for !bbs.menu_exists, etc.. it always comes back showing the mystique one. If I take the bbs.menu_exists test out, it works.
I've been using this for the last couple of years, which works but I want to clean it up a bit cause it's a bit messy:
function mystMenu(file) {
var ansiDir = system.text_dir + 'menu/' + user.command_shell + '/';
if (!file_exists(ansiDir + file + '.ans') && !file_exists(ansiDir + file + '.asc'))
var ansiDir = system.text_dir + 'menu/mystique/';
bbs.menu(ansiDir + file);
}
Thanks for your assistance, as always!ãã---ã þ Synchronet þ Capitol Shrill BBS - Washington, DC - capitolshrill.comã