Hi DM,
One of the mods/doors I've written which is in the Git repository is Good Time Trivia (in xtrn/gttrivia). I just noticed an odd issue with it - It seems the results of the directory() function are being affected by a console.yesno() at a different point in the script. However, if I try to reproduce it with a separate script using directory() and console.yesno(), I can't reproduce it. So I'm wondering if something else might be going on - though I don't know what that might be at this point.
Web link:
https://gitlab.synchro.net/main/sbbs/-/blob/master/xtrn/gttrivia/gttrivia.js
In gttrivia.js, on line 763 (in the getQACategoriesAndFilenames() function), it calls directory() to get a list of *.qa files (which are the category Q&A files):
var QAFilenames = directory(js.exec_dir + "qa/*.qa");
The game's main menu lets you view scores. On line 1420 (in the showScores() function), it uses console.yesno() to prompt whether you want to also view multi-BBS scores (in addition to local scores, which are shown before that).
What's happening is that after I view scores and that console.yesno() is executed, directory() is returning an empty array, rather than returning an array of the filenames. If I comment out that console.yesno() and just have that variable set to true or false, directory() successfully returns an array of the filenames each time.
However, I tried reproducing the issue with this JS snippet, and was not able to reproduce the issue:
var showServerScoresConfirm = console.yesno(i + ": Show multi-BBS scores");
var fileList = directory("/home/erico/BBS/sbbs/xtrn/DigDist/gttrivia/qa/*.qa"); console.print("# files: " + fileList.length + "\r\n");
for (var i = 0; i < fileList.length; ++i)
console.print(fileList[i] + "\r\n");
So, I can't think of a reason why this issue is happening in gttrivia.js..
I also tried putting my test block of code in a loop where it would run twice, and I noticed that it only ran once:
for (var i = 0; i < 2; ++i)
{
var showServerScoresConfirm = console.yesno(i + ": Show multi-BBS scores");
var fileList = directory("/home/erico/BBS/sbbs/xtrn/DigDist/gttrivia/qa/*.qa");
console.print("# files: " + fileList.length + "\r\n");
for (var i = 0; i < fileList.length; ++i)
console.print(fileList[i] + "\r\n");
}
I'm not sure if that odd behavior is related at all to the odd behavior with directory() in gttrivia.js..
Also, without printing the filenames, the inner block runs twice, as expected: for (var i = 0; i < 2; ++i)
{
var showServerScoresConfirm = console.yesno(i + ": Show multi-BBS scores");
var fileList = directory("/home/erico/BBS/sbbs/xtrn/DigDist/gttrivia/qa/*.qa");
console.print("# files: " + fileList.length + "\r\n");
}
I'm at a bit of a loss as to these issues.. I'm curious if you might have any ideas?
Nightfox
---
þ Synchronet þ Digital Distortion: digitaldistortionbbs.com