Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: for loop doesn't start on zero  (Read 2429 times)

0 Members and 1 Guest are viewing this topic.

fireside

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 211
    • View Profile
for loop doesn't start on zero
« on: March 18, 2007, 09:45:23 PM »

I can't seem to get the for loop to start on zero as in this code:
Code: [Select]
for(var i = 0;i<6;i=i+1)
{
 Game.Msg(i+1);
}
}

I tried using i+1 in the Msg to see if it wasn't printing zero, but it starts on 2.

edit: never mind
it must be the way Msg prints to the screen or the number of lines.  This code prints zero:
Code: [Select]
for(var i = 0;i<6;i=i+1)
{
 if(i == 0)Game.Msg("zero");
}


« Last Edit: March 18, 2007, 10:05:18 PM by fireside »
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: for loop doesn't start on zero
« Reply #1 on: March 18, 2007, 10:14:37 PM »

it was not a problem of Game.Msg per se. But your loop displayed too many entries and Game.Msg showed only the last ones. Try his code to see what I mean:

Code: WME Script
  1. for(var i = 0;i<65535;i=i+1)
  2. {
  3.    Game.Msg(i+1);
  4.    Sleep(1);
  5. }
  6.  
  7.  
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

fireside

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 211
    • View Profile
Re: for loop doesn't start on zero
« Reply #2 on: March 19, 2007, 12:53:20 AM »

Yeah, it shows the last 5 lines and I had one over, which kind of confused me a little.  One more thing I learned.
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: for loop doesn't start on zero
« Reply #3 on: March 19, 2007, 08:59:45 AM »

You got me scared for a moment ;)
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave
 

Page created in 0.057 seconds with 22 queries.