xdarkshadowx
2012-12-26 23:24:09
If I have a case, and I want it to do something if it doesn't run into the integers I gave it, how do I catch everything else?
2012-12-26 23:24:09
2012-12-26 23:28:38
2012-12-26 23:38:11
2012-12-26 23:39:09
procedure Something;
begin
case something of
//case stuff
end else //The stuff to do if it doesn't solve the case
end;
2012-12-27 00:47:32
From: Gucci
Basically:procedure Something;
begin
case something of
//case stuff
end else //The stuff to do if it doesn't solve the case
end;
From: xdarkshadowx
mmk, like such?
case findLocation(0) of
0: begin
Lave;
wait(25000 + random(5000));
end;
1: begin
inventory;
end;
else: begin
functionOrWhatNotHere();
end;
end;
would that work? or did I misunderstand the syntax?
case findLocation(0) of
0:
begin
Lave;
wait(25000 + random(5000));
end;
1:
inventory; //begin and end not needed if it's single statement
else // ':' is not required after 'else', 'then' etc in Pascal (needed in some other languages such as Python though)
functionOrWhatNotHere();
end;
2012-12-27 00:49:47
From: riwu
It should be encased within the case statement.
2012-12-27 01:16:56
From: Gucci
Should work fine there
From: Gucci
Basically:procedure Something;
begin
case something of
//case stuff
end else //The stuff to do if it doesn't solve the case
end;
2012-12-27 01:18:32
From: riwu
Would result in an syntax error.
You can think case statements as multiple statements of 'else if',
Hence the 'end else' here would be like directed at the 'case something of' instead of those 'else if' statements within the case construct ;)