I have another JS question - Using load() or the File object, is it
possible to read files in the script's current directory without specifying the full path, if the script is not in the SBBS exec directory?
Normally, I like to keep scripts that I develop in their own directory (not in the SBBS exec directory). However, if I use load() or the File class to open a file, specifying the current directory (i.e., file.open("./someFile.txt")), it is unable to load the file, even if it's
in the same directory as the JavaScript file.
Similarly, when using load() to load another .js file in the same
directory, specifying "./" in the filename doesn't seem to work unless the scripts are in the SBBS exec directory.
Is there a setting somewhere that can be changed for JavaScript file directories, similar to the path environment variable? Or is there something that can be done in JS to ensure that it looks in the current directory for load() and the File class?
You need to specify the absolute path or a relative path from "..". There trick where you can 'detect' the directory the script was loaded from usi JavaScript exception. Here's that trick (invented by Deuce):
Sysop: | digital man |
---|---|
Location: | Riverside County, California |
Users: | 1,043 |
Nodes: | 15 (0 / 15) |
Uptime: | 41:45:33 |
Calls: | 500,899 |
Calls today: | 2 |
Files: | 109,370 |
D/L today: |
4,715 files (479M bytes) |
Messages: | 304,224 |