Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Jscript ➜ freezing

freezing

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Kyrock   (20 posts)  Bio
Date Tue 14 Jul 2009 09:22 PM (UTC)
Message
for some reason when I set the j for loop to:
for (j = 0; j < theList.length; j++)

then mushClient freezes. I've also tried adding:
if (j < theList.length) {

before var affObj = new Affliction(theList[j]); (in bold) and ended up in the same result.

function sort(list)
{
  var listContents = world.getVariable(list);
  if (listContents != "" && listContents != " ")
  {
    if (listContents.search(",") >= 0)
    {
      var theList = listContents.split(",");world.note("theList length is: " + theList.length);
      world.setVariable(list,"");
      for (i = 0;i <= 99; i++)
      {
        for (j = 0; j <= theList.length; j++)
        {
          var affObj = new Affliction(theList[j]);
          
          if (i = affObj.order)
          {
            world.note(j);
            addItem(list,affObj.name);
          }
world.note("ending j loop");
        }//end j loop
world.note("ending i loop");
      }//end i loop
world.note("ending split if");
    }
world.note("ending check empty");
  }
}
Top

Posted by Nick Gammon   Australia  (23,169 posts)  Bio   Forum Administrator
Date Reply #1 on Wed 15 Jul 2009 05:46 AM (UTC)
Message

 if (i = affObj.order)
          {
            world.note(j);
            addItem(list,affObj.name);
          }


That changes the value of i, the loop will never end.

You mean:


 if (i == affObj.order)

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Kyrock   (20 posts)  Bio
Date Reply #2 on Wed 15 Jul 2009 08:20 PM (UTC)
Message
heh, I knew it had to do with a never ending loop I just couldn't see how... stupid mistake. Thanks for the help
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


15,040 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.