SRL Archive - Help and Support

GoTo Type?


WhoCares357

2008-04-05 15:09:50

What is the variable type in Scar that is used for the GoTo condition.

This works kinda like this: You declare the variable gotoHere (as what type I do not know). Then when you use it in the beginning of the script. You later call on it to go to that exact position of the script where you defined it.

I know Scar has something like this because I have used it before. I just forgot the syntax for it.

In C++, it would go something like this:
// goto loop example

#include <iostream>
using namespace std;

int main ()
{
int n=10;
loop: //define it here
cout << n << ", ";
n--;
if (n>0) goto loop; //use it here
cout << "FIRE!\n";
return 0;
}

In scar it should be something like
program New;
var
gotoHere: (datatype);

begin
gotoHere:
//do stuff
goto gotoHere;
end.

I'm probably wrong, but that's my best shot at it.

n3ss3s

2008-04-05 15:18:39

It's a label, my friend.

Go to Tutorial Island -> Search this forum or w/e -> "Labels" and you'll find Ejjman's tut and propably a few others :)

Btw, right syntax, but I believe you need to be in a loop to use GoTo.

EDIT: Ejj's tut is wrong, he is doing invalid jumps in there :(


program New;

Var
I, II: Integer;

Label Lol;

begin
Repeat
Lol: Writeln('Hello');
I := I + 1;
II := II + Random(2);
If I > 5 Then
If II < 5 Then
GoTo Lol
Else
Break;
Wait(200);
Until(False);
end.

That maybe helps you.

bullzeye95

2008-04-05 15:18:41

program New;
label goHere;

begin
goHere:
goto goHere
end.
:)

EDIT: Kinda beat… keep in mind, you can't use labels in loops or case statements (maybe something else too? I forgot)

WhoCares357

2008-04-05 15:21:02

Wow that was quick. Thanks guys. I'll make note of the restrictions bullzeye95. Thanks.

n3ss3s

2008-04-05 15:29:26

BullZeye, isn't that what I just did?

You were right about cases though.