Results 1 to 5 of 5

Thread: How to use Try/Except/Finally?

  1. #1
    Join Date
    May 2008
    Posts
    1,345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default How to use Try/Except/Finally?

    Ok, I searched Tutorial Island, I turned up SQUAT.

    This is what I understand:

    Try = Tries the code under it.
    Except = If the code under Try didn't work, goes to this.
    Finally = No matter what this gets executed.

    Is this right? If not, can you please clarify .

  2. #2
    Join Date
    Jul 2007
    Location
    Norway.
    Posts
    1,938
    Mentioned
    3 Post(s)
    Quoted
    0 Post(s)

    Default

    That is absolutely correct, sir.

    SCAR Code:
    try
      Something;
    except
      Something_Failed;
    finally
      No_Matter_What_Happens;
    end;

  3. #3
    Join Date
    May 2008
    Posts
    1,345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Alright, I wasn't 100% sure. Thanks .

    One last question:

    If I did this:

    Try
    If not Invfull Then
    Wait(100)
    Except
    Dropall;
    Finally
    Terminatescript;

    It would only go to except if the inventory is full, right?

  4. #4
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Sand Storm View Post
    Alright, I wasn't 100% sure. Thanks .

    One last question:

    If I did this:

    Try
    If not Invfull Then
    Wait(100)
    Except
    Dropall;
    Finally
    Terminatescript;

    It would only go to except if the inventory is full, right?
    Try except is used for runtime errors. It tries the code in the try part and if theres a runtime error (access violation, out of range error, etc) then it moves onto the except part. Finally is called no matter what. It does not work for if then statements.

  5. #5
    Join Date
    May 2008
    Posts
    1,345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Ah, alright. Thanks for clarifying.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Finally done it 8)
    By Floor66 in forum NOTA
    Replies: 4
    Last Post: 12-27-2008, 05:09 PM
  2. try - finally!
    By Sir R. M8gic1an in forum OSR Outdated Tutorials
    Replies: 7
    Last Post: 05-22-2008, 09:25 AM
  3. Finally on SRL
    By Monster Hack in forum Who Are You ? Who ? Who ?
    Replies: 2
    Last Post: 11-07-2006, 12:09 AM

Posting Permissions

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