• 2 questions

    From DesotoFireflite@VERT/VALHALLA to All on Fri Apr 8 17:45:57 2022
    1. - When I use console.gotoxy(0,24); it takes me to line 22, not 24. Is this a normal thing +/- a few lines, or is it supposed to be dead accurate.

    2. - what are the { and } used for. As far as I can tell be reading up, they are only deed for condition statements. Just trying to understand.

    Thanks

    SysOp: C.G. Learn, AKA: DesotoFireflite
    Valhalla Home Services! - (Synchronet) - bbs.valhallabbs.com:23
    A Gamers Paradise - Over 250 Registered Online Game Doors!

    --- Don't eat the yellow snow!
    þ Synchronet þ Valhalla Home Services þ USA þ http://valhalla.synchro.net
  • From Nightfox@VERT/DIGDIST to DesotoFireflite on Fri Apr 8 16:59:33 2022
    Re: 2 questions
    By: DesotoFireflite to All on Fri Apr 08 2022 05:45 pm

    1. - When I use console.gotoxy(0,24); it takes me to line 22, not 24. Is this a normal thing +/- a few lines, or is it supposed to be dead accurate.

    console.gotoxy() should be exactly accurate. Note that the X and Y cursor coordinates are 1-based. You may be off by 1.

    2. - what are the { and } used for. As far as I can tell be reading up, they are only deed for condition statements. Just trying to understand.

    There are several things { and } can be used for.
    1. To surround blocks of code that contain more than one statement, such as:
    if (x === 1)
    {
    console.print("x is 1");
    console.crlf();
    console.pause();
    }

    2. When defining functions:
    function printNumber(num)
    {
    console.print(num);
    }

    3. When defining objects:
    var anObj = {
    aNum: 1,
    aString: "String"
    };

    There may be more cases I'm not thinking of.

    Nightfox

    ---
    þ Synchronet þ Digital Distortion: digitaldistortionbbs.com
  • From DesotoFireflite@VERT/VALHALLA to Nightfox on Fri Apr 8 21:16:47 2022
    Re: 2 questions
    By: Nightfox to DesotoFireflite on Fri Apr 08 2022 04:59 pm

    Re: 2 questions
    By: DesotoFireflite to All on Fri Apr 08 2022 05:45 pm

    1. - When I use console.gotoxy(0,24); it takes me to line 22, not
    24. Is this a normal thing +/- a few lines, or is it supposed to be
    dead accurate.

    console.gotoxy() should be exactly accurate. Note that the X and Y cursor coordinates are 1-based. You may be off by 1.

    Ahhh, I do remember reading that somewhere, now it makes sense

    2. - what are the { and } used for. As far as I can tell be reading
    up, they are only deed for condition statements. Just trying to
    understand.

    There are several things { and } can be used for.
    1. To surround blocks of code that contain more than one statement, such as: if (x === 1)
    {
    console.print("x is 1");
    console.crlf();
    console.pause();
    }

    2. When defining functions:
    function printNumber(num)
    {
    console.print(num);
    }

    3. When defining objects:
    var anObj = {
    aNum: 1,
    aString: "String"
    };

    There may be more cases I'm not thinking of.

    OK, great, I can work with that, it's making sense to me now. Thanks for the help my friend. I really don't know why I waited so long to get into js.

    SysOp: C.G. Learn, AKA: DesotoFireflite
    Valhalla Home Services! - (Synchronet) - bbs.valhallabbs.com:23
    A Gamers Paradise - Over 250 Registered Online Game Doors!

    --- CAT (n.), Furry keyboard cover.
    þ Synchronet þ Valhalla Home Services þ USA þ http://valhalla.synchro.net
  • From echicken@VERT/ECBBS to DesotoFireflite on Sat Apr 9 03:56:38 2022
    Re: 2 questions
    By: DesotoFireflite to All on Fri Apr 08 2022 17:45:57

    1. - When I use console.gotoxy(0,24); it takes me to line 22, not 24. Is this a normal thing +/- a few lines, or is it supposed to be dead accurate.

    I believe these coordinates are 1-based, so the top left cell is 1,1. Even so I would only expect you to end up one row above where you intended. Not sure what's up with that.

    FYI if your intention is to move to the first column of the last line in the terminal, I would recommend:

    console.gotoxy(1, console.screen_rows);

    This will get you there no matter what the dimensions of the terminal are. (There is also a 'screen_columns' property.)

    2. - what are the { and } used for. As far as I can tell be reading up, they are only deed for condition statements. Just trying to understand.

    Curly braces do a few different things in JS, but mostly they're creating a 'block' to group several statements together. If your 'if' statement only needs to do one thing, then you don't need them:

    if (true) write('true');

    or even:

    if (true)
    write('true');

    If your 'if' statement needs to do multiple things, you'll want them:

    if (true) {
    write('true');
    write('okay');
    }

    Otherwise the interpreter wouldn't know where the 'if' ended.

    Same goes for 'for' loops and probably a couple other things. In other places, they are mandatory, like when defining a function using the 'function' keyword.

    A lot more could be said on the subject, and somebody probably will, but I won't flood you with info just yet.

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com
    ---
    þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.com
  • From DesotoFireflite@VERT/VALHALLA to echicken on Sat Apr 9 07:38:59 2022
    Re: 2 questions
    By: echicken to DesotoFireflite on Sat Apr 09 2022 03:56 am

    Re: 2 questions
    By: DesotoFireflite to All on Fri Apr 08 2022 17:45:57

    1. - When I use console.gotoxy(0,24); it takes me to line 22, not
    24. Is this a normal thing +/- a few lines, or is it supposed to be
    dead accurate.

    I believe these coordinates are 1-based, so the top left cell is 1,1. Even so I would only expect you to end up one row above where you intended. Not sure what's up with that.

    I was going to work on it some today. Nightfox reminded me about the "1 Bassed" reference yesterday, and I had not taken that into my thoughts.

    FYI if your intention is to move to the first column of the last line in the terminal, I would recommend:

    console.gotoxy(1, console.screen_rows);

    Wow, I didn't even see that in the Sync JS Object Model Reference, Thanks, I am going to try this, as it sounds to be just what I'm looking for.

    This will get you there no matter what the dimensions of the terminal are. (There is also a 'screen_columns' property.)


    2. - what are the { and } used for. As far as I can tell be reading
    up, they are only deed for condition statements. Just trying to
    understand.

    Curly braces do a few different things in JS, but mostly they're creating a 'block' to group several statements together. If your 'if' statement only needs to do one thing, then you don't need them:

    OK, I am onboard with this now, I'm just going to have to practice it abit to get familiar with it. I'm going to work on converting one of my baja mods into js. This should be quite a learning experience. As alway, thanks.

    SysOp: C.G. Learn, AKA: DesotoFireflite
    Valhalla Home Services! - (Synchronet) - bbs.valhallabbs.com:23
    A Gamers Paradise - Over 250 Registered Online Game Doors!

    --- Don't eat the yellow snow!
    þ Synchronet þ Valhalla Home Services þ USA þ http://valhalla.synchro.net