Results 1 to 10 of 10

Thread: if... then loop back?

  1. #1
    Join Date
    Dec 2011
    Location
    Toronto, Ontario
    Posts
    6,424
    Mentioned
    84 Post(s)
    Quoted
    863 Post(s)

    Default if... then loop back?

    Is there anyway to -

    Simba Code:
    procedure sfhsdibsi
    begin

    if someshit happens then
    begin
      dealwiththat
      loopbacktobeginning of procedure
    end;

    end;
    Help plox

  2. #2
    Join Date
    Nov 2006
    Posts
    2,369
    Mentioned
    4 Post(s)
    Quoted
    78 Post(s)

    Default

    Simba Code:
    procedure sfhsdibsi
    begin
      while someshit happens do
      begin
        dealwiththat
      end;

    end;
    Like that?
    Quote Originally Posted by DeSnob View Post
    ETA's don't exist in SRL like they did in other communities. Want a faster update? Help out with updating, otherwise just gotta wait it out.

  3. #3
    Join Date
    Dec 2007
    Posts
    2,112
    Mentioned
    71 Post(s)
    Quoted
    580 Post(s)

    Default

    Label's, i think
    why not just stick the whole thing in a repeat?

  4. #4
    Join Date
    Jan 2012
    Location
    Minneapolis, Mn
    Posts
    185
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Try something like this:

    Simba Code:
    procedure Recursion;
    begin
        if test then
           begin
               //stuff....
               Recursion;
          end;
    end;

  5. #5
    Join Date
    Sep 2007
    Location
    Michigan
    Posts
    3,862
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    This is why I use .Loc system.
    (Scripts outdated until I update for new SRL changes)
    AK Smelter & Crafter [SRL-Stats] - Fast Fighter [TUT] [SRL-Stats]
    If you PM me with a stupid question or one listed in FAQ I will NOT respond. -Narcle
    Summer = me busy, won't be around much.

  6. #6
    Join Date
    Dec 2007
    Posts
    2,112
    Mentioned
    71 Post(s)
    Quoted
    580 Post(s)

    Default

    that thread has a good example for label's they dont get used often
    http://villavu.com/forum/showthread.php?t=35035

    just saying

  7. #7
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    6,136
    Mentioned
    28 Post(s)
    Quoted
    17 Post(s)

    Default

    Quote Originally Posted by S1N View Post
    Is there anyway to -

    Simba Code:
    procedure sfhsdibsi
    begin

     repeat
       moreshitbackatbeginning;
       repeat
         lostofunneccesaryshit;
         if someshit happens then  
          begin
             dealwiththat
           break; // loopbacktobeginning of procedure
         end;
        until noshit
     until whateverstop
    end;
    Help plox
    I think I'd do it that way
    SRL is a Library of routines made by the SRL community written for the Program Simba.
    We produce Scripts for the game Runescape.

  8. #8
    Join Date
    Nov 2006
    Posts
    2,369
    Mentioned
    4 Post(s)
    Quoted
    78 Post(s)

    Default

    Quote Originally Posted by Inception View Post
    Try something like this:

    Simba Code:
    procedure Recursion;
    begin
        if test then
           begin
               //stuff....
               Recursion;
          end;
    end;
    I don't recommend doing this. With recursion it would use more memory and it will finish the procedure after the recursion is done. As far as I know you should only use recursion when you have to program a varying amount of loops inside loops.

    like..
    Simba Code:
    for
      for
         for
            for
               ...
    Last edited by weequ; 01-26-2012 at 12:48 AM.
    Quote Originally Posted by DeSnob View Post
    ETA's don't exist in SRL like they did in other communities. Want a faster update? Help out with updating, otherwise just gotta wait it out.

  9. #9
    Join Date
    Jan 2012
    Location
    Minneapolis, Mn
    Posts
    185
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by weequ View Post
    I don't recommend doing this. With recursion it would use more memory and it will finish the procedure after the recursion is done. As far as I know you should only use recursion when you have to program a varying amount of loops inside loops.
    You could just add an Exit after the recursion call, right?

    Simba Code:
    procedure Recursion;
    begin
        if test then
           begin
               //stuff....
               Recursion;
               Exit;
          end;
    end;
    Last edited by Inception; 01-26-2012 at 12:52 AM. Reason: Added code

  10. #10
    Join Date
    Nov 2006
    Posts
    2,369
    Mentioned
    4 Post(s)
    Quoted
    78 Post(s)

    Default

    Quote Originally Posted by Inception View Post
    You could just add an Exit after the recursion call, right?

    Simba Code:
    procedure Recursion;
    begin
        if test then
           begin
               //stuff....
               Recursion;
               Exit;
          end;
    end;
    Yup you could do that but I think there are better alternatives since the recursion has to keep the old function 'loaded' and will use more memory. (It performs the Recursion call before the exit)
    Last edited by weequ; 01-26-2012 at 01:03 AM.
    Quote Originally Posted by DeSnob View Post
    ETA's don't exist in SRL like they did in other communities. Want a faster update? Help out with updating, otherwise just gotta wait it out.

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
  •