Facility Control

 View Only
  • 1.  Simple "If statement" issue

    Posted 08-12-2022 16:09
    Hi all,

    Maybe I am just overlooking something really stupid and simple, but for the life of me I can't seem to get this to work:

    var name = params.getValue('HomeLT_Name_1', 0);
    var length = params.getValue('Home_Roster_NumberOfPlayers', 0);
    ogscript.debug("NAME IS " + name);
    for (var i = 0; i <= length; i++)
    {
      var tableName = params.getValue('homeRoster.' + i + '.name',0);
       ogscript.debug("COMPARING: " + name + "/" + tableName);
      if (name.equals(tableName))
    {
       ogscript.debug("NAME FOUND: " + name + " = " +  tableName);
     
       }
    else
    {
    ogscript.debug("NOT A MATCH");
    }
       
    }​

    I can see in the debug it does compare the right elements, and I can see the instance in which variables "name" and "tableName" match, but the if statement seems to not see it and I see "NOT A MATCH" for every comparison.

    I have also tried  "if (name == tableName)" instead of "if (name.equals(tableName))" but it is the same result with no matches found.

    Sorry if it is an easy solution, but I can't see what is wrong here, especially since I can see the instance in the debug code where the if statement should logically be true.



    ------------------------------
    Jake Lew
    Access Communications Co-Operative Limited
    ------------------------------


  • 2.  RE: Simple "If statement" issue

    Posted 08-12-2022 17:18
    Never mind, I found my issue.... I had a leading empty space character in my first parameter that threw it off. Whoops. Boy I sure wish I could delete threads now, haha.

    ------------------------------
    Jake Lew
    Access Communications Co-Operative Limited
    ------------------------------