• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] how to load every user.ini in scriptfiles using YINI
#31
Quote:you should remove return statement in loop because it stops the loop.
Not just the loop, though. Allow me to add this information for mems:
- "continue" stops the current iteration of the loop and goes to the next iteration (iteration is the right word, right?)
- "break" stops the current iteration and does not go to the next one: "break"ing the loop
- "return" stops the execution of the entire function (so everything after "return" would never run), and if something is specified (a return value) it returns that value to the calling function (if any).

Example using continue:
Code:
Foo()
{
    for (new i = 1; i <= 5; i)
    {
        if (i == 3) continue;
        printf("i=%i", i);
    }
    print("This must be printed!");
}
Output would be:
Quote:1
2
4
5
This must be printed!

Example using break:
Code:
Foo()
{
    for (new i = 1; i <= 5; i)
    {
        if (i == 3) break;
        printf("i=%i", i);
    }
    print("This must be printed!");
}
Output would be:
Quote:1
2
This must be printed!

Example using return:
Code:
Foo()
{
    for (new i = 1; i <= 5; i)
    {
        if (i == 3) return;
        printf("i=%i", i);
    }
    print("This must be printed!");
}
Output would be:
Quote:1
2


I've seen beginners misusing this quite some times, hence this information examples.
  Reply


Messages In This Thread
RE: how to load every user.ini in scriptfiles using YINI - by Kwarde - 2021-02-16, 06:01 AM

Forum Jump: