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?
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?
Have an else statement after the cases. It will be executed if the value doesn't meet any of the cases.
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?
Basically:
Simba Code:procedure Something;
begin
case something of
//case stuff
end else //The stuff to do if it doesn't solve the case
end;
Current Project: Retired
It should be encased within the case statement.
Simba Code: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;
There are currently 1 users browsing this thread. (0 members and 1 guests)