• 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ãã De> 1. - When I use console.gotoxy(0,24); it takes me to line 22, not 24. Isã De> this a normal thing +/- a few lines, or is it supposed to be deadã De> accurate. ããconsole.gotoxy() should be exactly accurate. Note that the X and Y cursor coordinates are 1-based. You may be off by 1.ãã De> 2. - what are the { and } used for. As far as I can tell be reading up,ã De> 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ãã Ni> Re: 2 questionsã Ni> By: DesotoFireflite to All on Fri Apr 08 2022 05:45 pmãã De>> 1. - When I use console.gotoxy(0,24); it takes me to line 22, notã De>> 24. Is this a normal thing +/- a few lines, or is it supposed to beã De>> dead accurate. ãã Ni> console.gotoxy() should be exactly accurate. Note that the X and Y cursorã Ni> coordinates are 1-based. You may be off by 1.ããAhhh, I do remember reading that somewhere, now it makes senseãã De>> 2. - what are the { and } used for. As far as I can tell be readingã De>> up, they are only deed for condition statements. Just trying toã De>> understand. ãã Ni> There are several things { and } can be used for.ã Ni> 1. To surround blocks of code that contain more than one statement, suchã Ni> as: if (x === 1)ã Ni> {ã Ni> console.print("x is 1");ã Ni> console.crlf();ã Ni> console.pause();ã Ni> }ãã Ni> 2. When defining functions:ã Ni> function printNumber(num)ã Ni> {ã Ni> console.print(num);ã Ni> }ãã Ni> 3. When defining objects:ã Ni> var anObj = {ã Ni> aNum: 1,ã Ni> aString: "String"ã Ni> };ãã Ni> 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ãã De> 1. - When I use console.gotoxy(0,24); it takes me to line 22, not 24. Isã De> this a normal thing +/- a few lines, or is it supposed to be deadã De> 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.)ãã De> 2. - what are the { and } used for. As far as I can tell be reading up,ã De> 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ãã ec> Re: 2 questionsã ec> By: DesotoFireflite to All on Fri Apr 08 2022 17:45:57ãã De>> 1. - When I use console.gotoxy(0,24); it takes me to line 22, notã De>> 24. Is this a normal thing +/- a few lines, or is it supposed to beã De>> dead accurate. ãã ec> I believe these coordinates are 1-based, so the top left cell is 1,1. Evenã ec> so I would only expect you to end up one row above where you intended. Notã ec> 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.ãã ec> FYI if your intention is to move to the first column of the last line inã ec> the terminal, I would recommend:ãã ec> 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. ãã ec> This will get you there no matter what the dimensions of the terminal are.ã ec> (There is also a 'screen_columns' property.)ããã De>> 2. - what are the { and } used for. As far as I can tell be readingã De>> up, they are only deed for condition statements. Just trying toã De>> understand. ãã ec> Curly braces do a few different things in JS, but mostly they're creatingã ec> a 'block' to group several statements together. If your 'if' statementã ec> 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ã