SRL Archive - RuneScape News and General

If sentence need help


Laimonas171

2012-10-20 05:56:56

Hi guys.

i wanted to ask is it possible to to sth like at php


if($pos==true){
echo "true";
}elseif($pos==False){
echo "false";
}elseif(!isset($pos)){
echo "pos is not set";
}

 
if FindSymbol(x, y, 'water') then
if FindSymbol(x, y, 'quest') then
if FindSymbol(x, y, 'shop') then
begin
WriteLn(' true');
end else
begin
WriteLn(' false');
end;
//how do o do "else if" or sth similar?


Edit: Silly my. probably something like that? or here is any option to do else if sentence?

 
if FindSymbol(x, y, 'water') then
if FindSymbol(x, y, 'quest') then
if FindSymbol(x, y, 'shop') then
begin
WriteLn(' true');
end else
begin
if not FindSymbol(x, y, 'water') then
if not FindSymbol(x, y, 'quest') then
if not FindSymbol(x, y, 'shop') then
begin
WriteLn('false');
end else
begin
WriteLn('third option');
end;

end;
//sth like this? or here is something not so deep as in php?



———————————————

Another Question:

how can I create function / procedure which returns me true or false value.

i imagine something like this. but not sure or it's ok

Procedure returnTrueOrFalse;
begin
if FindSymbol(x, y, 'tree') then
begin
return true;
end else
begin
return false;
end;
end;

Procedure checkWhatIsReturned;
begin
if returnTrueOrFalse then
begin
WriteLn('Returned True');
end else
WriteLN('Returned False');
end;
end;

riwu

2012-10-20 06:47:10

If what you are trying to do is that it returns true if any of them are found, then do:
if FindSymbolsMulti(TPA, ['water', 'quest', 'shop']) then
writeln(true)
else
writeln(false);

Declare the TPA as a TPointArray.
For more advanced usage, you can check Length(TPA) to find out how many symbols are found.

Only a function can return a value (a procedure can however, store the result in param as well):
function returnTrueOrFalse: Boolean;
var
x,y: Integer;
begin
Result:= FindSymbol(x, y, 'tree'); //i assign the Result directly to FindSymbol, which returns true if found, and false otherwise
end;

You are right about how to use it, but you dont need a begin and end for 1 action:
if returnTrueOrFalse then
WriteLn('Returned True') //notice we dont put a semicolon since we are adding else
else
WriteLN('Returned False');

Although 1 liner function are pretty pointless most of the time, as you can just directly check for FindSymbol in that procedure.

Rezozo

2012-10-20 06:51:03

Nin.J.A!
But basically yea, basic pascal wise, you could put:
If (condition) and (condition2) then
(do stuff)
else (do something else)

As said above, you could do that too. To me it is simpler to assign a boolean value as global, and change it during the procedure, so when called, it remains that value.

Laimonas171

2012-10-20 07:07:06

Thank you guys!