SRL Archive - OSR Help

Continue; <-- What does it do?


Cstrike

2010-11-11 12:30:08

Is there anywhere I can find the documented functions? I don't know what Continue; does

For example:
begin
for I := 1 to 28 do
begin
Item := GetInvItemAt(I);
if(InIntArray(IDs, Item.ID)) then Continue;
R_ClickItem(I, False, 'Deposit-All');
end;
end;

I want to add a wait in here and change it around slightly so that reflection can be updated (since this code works great but Jagex did an update and Deposit-All doesn't exist for single items now).

So: What does Continue; do?

Quickmarch

2010-11-11 12:38:46

It proceeds to the next iteration of the loop.

TomTuff

2010-11-11 12:42:01

From: Quickmarch
It proceeds to the next iteration of the loop.


then what's the point?

is it like

if not(situation) then Break;

?

Quickmarch

2010-11-11 12:55:46


for i := 0 to 9 do
begin
if (i = 3) then continue;
WriteLn(i);
end;

will skip the 4th iteration.

Sandstorm

2010-11-11 13:04:19

It continues the loop from the start - skipping whatever is after it.

In his code, if I = 3 (the fourth loop through), it won't write 3, it will skip from 2 to 4.

HyperSecret

2010-11-11 13:51:55

From: cstrike
Is there anywhere I can find the documented functions? I don't know what Continue; does

For example:
begin
for I := 1 to 28 do
begin
Item := GetInvItemAt(I);
if(InIntArray(IDs, Item.ID)) then Continue;
R_ClickItem(I, False, 'Deposit-All');
end;
end;

I want to add a wait in here and change it around slightly so that reflection can be updated (since this code works great but Jagex did an update and Deposit-All doesn't exist for single items now).

So: What does Continue; do?


In your situation cstrike, if Item.ID is in the IDs array then it 'Skip' that item in the array and not do R_ClickItem() on that inventory spot (since 1 to 28 is the inventory).

So lets say, your array IDs = {1128, 1129, 1130};
If the ID for the Item from 'Item := GetInvItemAt(i)' matches any of the IDs in array IDs it will go to the next inventory spot (or the next 'i' iteration).

This is what the "Continue" does…When Item.ID matches one of the items in the IDs array then it will go back to the top of the for loop and increment i. So R_ClickItem() is not executed/called.

Ejjman

2011-01-08 16:15:04

From: HyperSecret
In your situation cstrike, if Item.ID is in the IDs array then it 'Skip' that item in the array and not do R_ClickItem() on that inventory spot (since 1 to 28 is the inventory).

So lets say, your array IDs = {1128, 1129, 1130};
If the ID for the Item from 'Item := GetInvItemAt(i)' matches any of the IDs in array IDs it will go to the next inventory spot (or the next 'i' iteration).

This is what the "Continue" does…When Item.ID matches one of the items in the IDs array then it will go back to the top of the for loop and increment i. So R_ClickItem() is not executed/called.


I know this is really old, but why would the person not just do this

begin
for I := 1 to 28 do
begin
Item := GetInvItemAt(I);
if(InIntArray(IDs, Item.ID)) then R_ClickItem(I, False, 'Deposit-All');
end;
end;

NCDS

2011-01-08 16:26:00

From: Ejjman1
I know this is really old, but why would the person not just do this

begin
for I := 1 to 28 do
begin
Item := GetInvItemAt(I);
if(InIntArray(IDs, Item.ID)) then R_ClickItem(I, False, 'Deposit-All');
end;
end;


You could if that's what you wanted to do. 'Continue;' just skips to the end of the loop which is useful for things like:

for i := 0 to High(Objects) do
begin
if FindObject(Objects[i], ...) then //Just for an example
Continue
else begin
WalkHere;
DoThis;
end;
Wait(3000);
Writeln('not found');
end;
In the above example if 'Continue;' is called, it will skip:

else begin
WalkHere;
DoThis;
end;
Wait(3000);
Writeln('not found');

Ejjman

2011-01-08 16:34:34

Ahh, now I remember. Thanks for that :)