Hi am I supposed to use sbbsdefs.js and userdefs.js in the same script?
I'm using several properties from userdefs so I have
require("sbbsdefs.js", 'USER_EXPERT');
load("userdefs.js");
but my script complains about
TypeError: redeclaration of const USER_DELETED
Since sbbsdefs is only importing USER_EXPERT, shouldn't it ignore the definition of USER_DELETED ? And why would it be defined in there when it's already defined in userdefs.js?
Nightfox suggested if I use require with userdefs then it might look at the other properties anyway, but that's not the case.
Would appreciate some advice please.
No, since sbbsdefs.js already requires userdefs.js, you don't need to use (load or require) both.
The second argument to require() is just one variable name that you expect to be defined in the required script, not all of the variable names that you expect to be defined. The entire script that you require() is evaluated if the specified named variable is not defined.
Re: Using sbbsdefs and userdefs
By: Digital Man to Nelgin on Wed Aug 16 2023 12:59 pm
The second argument to require() is just one variable name that you expect to be defined in the required script, not all of the variable names that you expect to be defined. The entire script that you require() is evaluated if the specified named variable is not defined.
So for require(), if you want to be able to use everything from the required file, would you omit the 2nd argument (or pass an empty string)?
In my .js
scripts, I have passed a variable name as the 2nd argument for require(), and I have been able to use other variables from that .js as well.
So for require(), if you want to be able to use everything from the
required file, would you omit the 2nd argument (or pass an empty string)?
No, you would pass *one* of your *required* symbols (functions or variables) from the child script. Anything else defined in that file just comes along for free.
Sysop: | StingRay |
---|---|
Location: | Woodstock, GA |
Users: | 30 |
Nodes: | 15 (0 / 15) |
Uptime: | 25:49:23 |
Calls: | 594 |
Calls today: | 1 |
Files: | 377 |
Messages: | 228,778 |