Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Tech Support (https://forums.graalonline.com/forums/forumdisplay.php?f=7)
-   -   Printf() in loops (https://forums.graalonline.com/forums/showthread.php?t=73848)

Twinny 05-06-2007 10:48 AM

Printf() in loops
 
Using printf() in loops seems to break the loop.
PHP Code:

function onCreated()
{
  
this.array ={"I","really","really","like","pie"};
  for (
temp.this.array)
    
printf("[Blah?]: %s",temp.t);
  echo(
"--");
  for (
temp.this.array)
    echo(
format("[Blah?]: %s",temp.t));  


echos
PHP Code:

[Blah?]: I
--
[
Blah?]: I
[Blah?]: really
[Blah?]: really
[Blah?]: like
[Blah?]: pie 

Any idea why printf is breaking the loop? This was tested on Zodiac.

Chandler 05-06-2007 11:49 AM

Weird
HTML Code:

function onCreated()
{
  temp.myARRAY = {"hey", "hi", "test"};
  for (temp.currentWord: temp.myARRAY)
  {
    printf(temp.currentWord);
    printf("Called");
  }
  printf("Done");
}

It displays each one that is called.

Also, why're you using printf?

Twinny 05-06-2007 11:57 AM

Printf is a combination of echo() and format(): It is quite handy. P.s. did you actually test that code?

Chandler 05-06-2007 12:00 PM

I tested mine, why?

Twinny 05-06-2007 12:04 PM

I tested your code on two seperate servers and the results were:
PHP Code:

hey
Called
Done 

Signifying that there is a problem with printf() and loops. Well, I went straight to the source.
Quote:

Originally Posted by Stefan on Zodiac RC
Weapon/GUI-script Twinny/Testing added/updated by Stefan
*Stefan: hmmm weird
*Stefan: will need to check it


Chandler 05-06-2007 12:06 PM

Quote:

Originally Posted by Twinny (Post 1305843)
I tested your code on two seperate servers and the results were:
PHP Code:

hey
Called
Done 

Signifying that there is a problem with printf() and loops.

Oh, I didn't word it right.
I got the same as you, however it doesn't break the current loop. [It carries on...]

Twinny 05-06-2007 12:08 PM

Quote:

Originally Posted by Chandler (Post 1305845)
Oh, I didn't word it right.
I got the same as you, however it doesn't break the loop. [It carries on...]

Yes, it breaks the loop and carries on with the rest of the script :rolleyes:. It only echos "Called" once after all.

Twinny 05-12-2007 10:38 AM

*coughhackcough*

:confused:

Admins 05-21-2007 10:53 AM

Ok fixed it, will upload new npcservers soon.

Twinny 05-21-2007 02:38 PM

When will the next client be released? (It happens both clientside and serverside)

Admins 05-21-2007 06:28 PM

Client - probably in a few weeks
Server - already uploaded to all machines


All times are GMT +2. The time now is 02:49 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.