Results 1 to 4 of 4

Thread: If sentence need help

  1. #1
    Join Date
    Nov 2008
    Location
    Norway, Alesund
    Posts
    924
    Mentioned
    0 Post(s)
    Quoted
    37 Post(s)

    Default If sentence need help

    Hi guys.

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

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

    Simba Code:
    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?

    Simba Code:
    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
    Simba Code:
    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;

  2. #2
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    If what you are trying to do is that it returns true if any of them are found, then do:
    Simba Code:
    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):
    Simba Code:
    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:
    Simba Code:
    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.

  3. #3
    Join Date
    Dec 2011
    Location
    Nj
    Posts
    2,341
    Mentioned
    1 Post(s)
    Quoted
    18 Post(s)

    Default

    Nin.J.A!
    But basically yea, basic pascal wise, you could put:
    Simba Code:
    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.

    For the basics of the basics of pascal, try my TuT. ||Photoshop Editing ||MapleResourceDung Script || Book a flight! BuySellTrip

  4. #4
    Join Date
    Nov 2008
    Location
    Norway, Alesund
    Posts
    924
    Mentioned
    0 Post(s)
    Quoted
    37 Post(s)

    Default

    Thank you guys!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •