• Using sbbsdefs and userdefs

    From Nelgin@VERT/EOTLBBS to digital man on Wednesday, August 16, 2023 14:12:36
    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.

    Thanks,
    ---
    ■ Synchronet ■ End Of The Line BBS - endofthelinebbs.com
  • From Digital Man@VERT to Nelgin on Wednesday, August 16, 2023 12:59:03
    Re: Using sbbsdefs and userdefs
    By: Nelgin to digital man on Wed Aug 16 2023 02:12 pm

    Hi am I supposed to use sbbsdefs.js and userdefs.js in the same script?

    No, since sbbsdefs.js already requires userdefs.js, you don't need to use (load or require) both.

    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

    Using require() instead of load() would fix that.

    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.

    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.
    --
    digital man (rob)

    This Is Spinal Tap quote #11:
    Nigel Tufnel: No. no. That's it, you've seen enough of that one.
    Norco, CA WX: 95.9°F, 35.0% humidity, 4 mph E wind, 0.00 inches rain/24hrs
    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From Nelgin@VERT/EOTLBBS to Digital Man on Wednesday, August 16, 2023 15:11:40
    Re: Using sbbsdefs and userdefs
    By: Digital Man to Nelgin on Wed Aug 16 2023 12:59:03

    No, since sbbsdefs.js already requires userdefs.js, you don't need to use (load or require) both.

    OK got it. I think the problem stemmed from me accidentally removing the require for text.js. I added that back and it's good now.

    Thanks for the response.
    ---
    ■ Synchronet ■ End Of The Line BBS - endofthelinebbs.com
  • From Nightfox@VERT/DIGDIST to Digital Man on Wednesday, August 16, 2023 14:11:07
    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.

    Nightfox

    ---
    ■ Synchronet ■ Digital Distortion: digitaldistortionbbs.com
  • From Digital Man@VERT to Nightfox on Wednesday, August 16, 2023 14:35:55
    Re: Using sbbsdefs and userdefs
    By: Nightfox to Digital Man on Wed Aug 16 2023 02:11 pm

    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)?

    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.

    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.

    Right, and that's how it's supposed to work.
    --
    digital man (rob)

    Breaking Bad quote #13:
    I got twenty bucks that says he's a beaner. - Hank Schrader
    Norco, CA WX: 96.6°F, 31.0% humidity, 10 mph SSE wind, 0.00 inches rain/24hrs ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From Nightfox@VERT/DIGDIST to Digital Man on Wednesday, August 16, 2023 15:08:26
    Re: Using sbbsdefs and userdefs
    By: Digital Man to Nightfox on Wed Aug 16 2023 02:35 pm

    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.

    That's what I remembered (and how it seemes to be working).. Just wanted to make sure.

    Nightfox

    ---
    ■ Synchronet ■ Digital Distortion: digitaldistortionbbs.com