• Option list selection

    From =?UTF-8?Q?Jonas_Th=C3=B6rnvall?=@21:1/5 to All on Mon Nov 1 02:23:53 2021
    I am pretty sure this code did run a week ago, have their been changes to the API it seem it never enter loop because e.options.length undefined?

    function getPortIndex(){
    var e = parent.document.getElementById("out_portsel");
    alert(parent.out_portsel.length);
    for (var i=0;i<parent.out_portsel.length;i++){
    alert("WTF");
    if (e.options[i].value=="FW1884 Control"){ctrlportindex=i; alert(ctrlportindex); break;}
    else{alert("nonevalid port");}
    }
    }

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Jonas_Th=C3=B6rnvall?=@21:1/5 to All on Mon Nov 1 02:28:21 2021
    måndag 1 november 2021 kl. 10:23:57 UTC+1 skrev Jonas Thörnvall:
    I am pretty sure this code did run a week ago, have their been changes to the API it seem it never enter loop because e.options.length undefined?

    function getPortIndex(){
    var e = parent.document.getElementById("out_portsel"); alert(parent.out_portsel.length);
    for (var i=0;i<parent.out_portsel.length;i++){
    alert("WTF");
    if (e.options[i].value=="FW1884 Control"){ctrlportindex=i; alert(ctrlportindex); break;}
    else{alert("nonevalid port");}
    }
    }
    Changed to e.length now it work, but i am pretty sure i used length of the form last week.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From luserdroog@21:1/5 to jonas.t...@gmail.com on Mon Nov 1 09:17:20 2021
    On Monday, November 1, 2021 at 4:23:57 AM UTC-5, jonas.t...@gmail.com wrote:
    I am pretty sure this code did run a week ago, have their been changes to the API it seem it never enter loop because e.options.length undefined?

    function getPortIndex(){
    var e = parent.document.getElementById("out_portsel");
    alert(parent.out_portsel.length);
    for (var i=0;i<parent.out_portsel.length;i++){
    alert("WTF");
    if (e.options[i].value=="FW1884 Control"){ctrlportindex=i; alert(ctrlportindex); break;}
    else{alert("nonevalid port");}
    }
    }

    Here again, I think this code could be factored to be easier to read and verify.

    let E = (x)=>parent.document.getElementById(x);

    function getPortIndex(){
    let e = E("out_portsel");
    return e.options.findIndex( (opt)=>opt.value=="FW1884 Control" );
    }

    I started to write a findfirst() function using .forEach() but after glancing at online refs I noticed .findIndex() which does all the looping business. There is a difference here in that my version uses the length of
    e.options[] instead of parent.out_portsel[] but that part doesn't really
    make sense to me so I'm not sure if it's important. If they're not the same,
    it might be worth investigating that so functions like this can be short
    and sweet.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Jonas_Th=C3=B6rnvall?=@21:1/5 to All on Mon Nov 1 15:10:16 2021
    måndag 1 november 2021 kl. 17:17:25 UTC+1 skrev luser...@gmail.com:
    On Monday, November 1, 2021 at 4:23:57 AM UTC-5, jonas.t...@gmail.com wrote:
    I am pretty sure this code did run a week ago, have their been changes to the API it seem it never enter loop because e.options.length undefined?

    function getPortIndex(){
    var e = parent.document.getElementById("out_portsel"); alert(parent.out_portsel.length);
    for (var i=0;i<parent.out_portsel.length;i++){
    alert("WTF");
    if (e.options[i].value=="FW1884 Control"){ctrlportindex=i; alert(ctrlportindex); break;}
    else{alert("nonevalid port");}
    }
    }
    Here again, I think this code could be factored to be easier to read and verify.

    let E = (x)=>parent.document.getElementById(x);

    function getPortIndex(){
    let e = E("out_portsel");
    return e.options.findIndex( (opt)=>opt.value=="FW1884 Control" );
    }

    I started to write a findfirst() function using .forEach() but after glancing
    at online refs I noticed .findIndex() which does all the looping business. There is a difference here in that my version uses the length of
    e.options[] instead of parent.out_portsel[] but that part doesn't really make sense to me so I'm not sure if it's important. If they're not the same, it might be worth investigating that so functions like this can be short
    and sweet.
    Can't say i like the Javascript syntax though what is the (opt)=> about and why is it necessary?
    Why not just e.options.findIndex( (opt.value=="FW1884 Control" );

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Jonas_Th=C3=B6rnvall?=@21:1/5 to All on Mon Nov 1 15:05:39 2021
    måndag 1 november 2021 kl. 17:17:25 UTC+1 skrev luser...@gmail.com:
    On Monday, November 1, 2021 at 4:23:57 AM UTC-5, jonas.t...@gmail.com wrote:
    I am pretty sure this code did run a week ago, have their been changes to the API it seem it never enter loop because e.options.length undefined?

    function getPortIndex(){
    var e = parent.document.getElementById("out_portsel"); alert(parent.out_portsel.length);
    for (var i=0;i<parent.out_portsel.length;i++){
    alert("WTF");
    if (e.options[i].value=="FW1884 Control"){ctrlportindex=i; alert(ctrlportindex); break;}
    else{alert("nonevalid port");}
    }
    }
    Here again, I think this code could be factored to be easier to read and verify.

    let E = (x)=>parent.document.getElementById(x);

    function getPortIndex(){
    let e = E("out_portsel");
    return e.options.findIndex( (opt)=>opt.value=="FW1884 Control" );
    }

    I started to write a findfirst() function using .forEach() but after glancing
    at online refs I noticed .findIndex() which does all the looping business. There is a difference here in that my version uses the length of
    e.options[] instead of parent.out_portsel[] but that part doesn't really make sense to me so I'm not sure if it's important. If they're not the same, it might be worth investigating that so functions like this can be short
    and sweet.
    Nice.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From luserdroog@21:1/5 to jonas.t...@gmail.com on Mon Nov 1 19:24:12 2021
    On Monday, November 1, 2021 at 5:10:23 PM UTC-5, jonas.t...@gmail.com wrote:
    måndag 1 november 2021 kl. 17:17:25 UTC+1 skrev luser...@gmail.com:
    On Monday, November 1, 2021 at 4:23:57 AM UTC-5, jonas.t...@gmail.com wrote:
    I am pretty sure this code did run a week ago, have their been changes to the API it seem it never enter loop because e.options.length undefined?

    function getPortIndex(){
    var e = parent.document.getElementById("out_portsel"); alert(parent.out_portsel.length);
    for (var i=0;i<parent.out_portsel.length;i++){
    alert("WTF");
    if (e.options[i].value=="FW1884 Control"){ctrlportindex=i; alert(ctrlportindex); break;}
    else{alert("nonevalid port");}
    }
    }
    Here again, I think this code could be factored to be easier to read and verify.

    let E = (x)=>parent.document.getElementById(x);

    function getPortIndex(){
    let e = E("out_portsel");
    return e.options.findIndex( (opt)=>opt.value=="FW1884 Control" );
    }

    I started to write a findfirst() function using .forEach() but after glancing
    at online refs I noticed .findIndex() which does all the looping business. There is a difference here in that my version uses the length of e.options[] instead of parent.out_portsel[] but that part doesn't really make sense to me so I'm not sure if it's important. If they're not the same,
    it might be worth investigating that so functions like this can be short and sweet.
    Can't say i like the Javascript syntax though what is the (opt)=> about and why is it necessary?
    Why not just e.options.findIndex( (opt.value=="FW1884 Control" );

    That's a good question. I believe it's part of a batch of features added to IIRC Ecma 5 (and more in 6) to support functional programming.
    A lot of the array methods are really nice for replacing loops of various kinds. But the price is you have to do it "functionally" which means
    passing in a function. It doesn't have to use the array syntax.

    You could also write it like:
    e.options.findIndex( function(opt){ return opt.value=="FW1884 Control"; } );

    But the code in middle (the *predicate* here, because it returns a boolean)
    has to be wrapped up in a function. I like the arrow syntax because it
    feels very lightweight and direct, but not everyone likes it. That's a valid reaction. It does look weird.

    This is a change I had to learn (twice) in my programming life. First in college,
    then again years later when I picked it back up as a hobby. The downside is
    you never stop hunting bugs, but the bugs get weirder and more interesting. I've been scratching my head for weeks over a 200 line program in PostScript that does (tries to do) parsing of regular expressions using parser combinators.
    It's only 200 lines, but I can't find the bug! But I don't envy what the task would be like if the program were 2000 or 20000 lines.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Julio Di Egidio@21:1/5 to luser...@gmail.com on Mon Nov 1 23:54:15 2021
    On Tuesday, 2 November 2021 at 03:24:16 UTC+1, luser...@gmail.com wrote:
    On Monday, November 1, 2021 at 5:10:23 PM UTC-5, jonas.t...@gmail.com wrote:

    Can't say i like the Javascript syntax though what is the (opt)=> about and why is it necessary?
    Why not just e.options.findIndex( (opt.value=="FW1884 Control" );
    That's a good question. I believe it's part of a batch of features added to

    It's a stupid question but your answer it's an even worse pile of pure crap:
    as usual, your incompetence is second only to your arrogance.

    When Dunning-Kruger is a compliment...

    *Plonk*

    Julio

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From luserdroog@21:1/5 to ju...@diegidio.name on Tue Nov 2 05:21:15 2021
    On Tuesday, November 2, 2021 at 1:54:20 AM UTC-5, ju...@diegidio.name wrote:
    On Tuesday, 2 November 2021 at 03:24:16 UTC+1, luser...@gmail.com wrote:
    On Monday, November 1, 2021 at 5:10:23 PM UTC-5, jonas.t...@gmail.com wrote:

    Can't say i like the Javascript syntax though what is the (opt)=> about and why is it necessary?
    Why not just e.options.findIndex( (opt.value=="FW1884 Control" );
    That's a good question. I believe it's part of a batch of features added to
    It's a stupid question but your answer it's an even worse pile of pure crap: as usual, your incompetence is second only to your arrogance.

    When Dunning-Kruger is a compliment...

    *Plonk*

    Dude, chill the fuck out.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jon Ribbens@21:1/5 to luserdroog on Tue Nov 2 12:41:54 2021
    On 2021-11-02, luserdroog <luser.droog@gmail.com> wrote:
    On Tuesday, November 2, 2021 at 1:54:20 AM UTC-5, ju...@diegidio.name wrote:
    On Tuesday, 2 November 2021 at 03:24:16 UTC+1, luser...@gmail.com wrote:
    On Monday, November 1, 2021 at 5:10:23 PM UTC-5, jonas.t...@gmail.com wrote:

    Can't say i like the Javascript syntax though what is the (opt)=> about and why is it necessary?
    Why not just e.options.findIndex( (opt.value=="FW1884 Control" );
    That's a good question. I believe it's part of a batch of features added to
    It's a stupid question but your answer it's an even worse pile of pure crap: >> as usual, your incompetence is second only to your arrogance.

    When Dunning-Kruger is a compliment...

    *Plonk*

    Dude, chill the fuck out.

    Don't worry about Julio the Plonker, he just gibbers non-stop
    foul-mouthed nonsense into the group. Killfiling him is the
    recommended solution.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From luserdroog@21:1/5 to Jon Ribbens on Wed Nov 3 16:15:01 2021
    On Tuesday, November 2, 2021 at 7:42:02 AM UTC-5, Jon Ribbens wrote:
    On 2021-11-02, luserdroog <luser...@gmail.com> wrote:
    On Tuesday, November 2, 2021 at 1:54:20 AM UTC-5, ju...@diegidio.name wrote:
    On Tuesday, 2 November 2021 at 03:24:16 UTC+1, luser...@gmail.com wrote: >> > On Monday, November 1, 2021 at 5:10:23 PM UTC-5, jonas.t...@gmail.com wrote:

    Can't say i like the Javascript syntax though what is the (opt)=> about and why is it necessary?
    Why not just e.options.findIndex( (opt.value=="FW1884 Control" );
    That's a good question. I believe it's part of a batch of features added to
    It's a stupid question but your answer it's an even worse pile of pure crap:
    as usual, your incompetence is second only to your arrogance.

    When Dunning-Kruger is a compliment...

    *Plonk*

    Dude, chill the fuck out.
    Don't worry about Julio the Plonker, he just gibbers non-stop
    foul-mouthed nonsense into the group. Killfiling him is the
    recommended solution.

    You're right. I overreacted. I thought I'd made some progress with Julio in our last exchange. I apologize for increasing the foul-mouthedness.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)