Results 1 to 7 of 7

Thread: End Else

  1. #1
    Join Date
    Sep 2008
    Location
    My House
    Posts
    519
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default End Else

    I have a procedure that has a If, Then, end else statement. Is it possible to do another end else. Like this...

    Code:
    If Then
    begin
    end else
    end else
    Or is there something like that?

  2. #2
    Join Date
    Oct 2006
    Location
    ithurtsithurtsithurtsithurts
    Posts
    2,930
    Mentioned
    7 Post(s)
    Quoted
    135 Post(s)

    Default

    Sort of. You'd have to do this:
    SCAR Code:
    if .. then
    begin
      ...
    end else if ..
    begin
      ...
    end else
    begin
      ...
    end;

    You'd use else if (something) for each one save the last.

  3. #3
    Join Date
    Sep 2008
    Location
    My House
    Posts
    519
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    oh thanks

  4. #4
    Join Date
    Oct 2009
    Location
    Stockton, CA
    Posts
    2,040
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    No, you don't.
    SCAR Code:
    program New;
    var
      wat : integer;
    begin
      wat := 2;
      if wat = 0 then
        writeln('Wat is zero.')
      else if wat = 1 then
        writeln('Wat is one')
      else if wat = 2 then
        writeln('Wat is two.');
    end.
    Join the IRC! irc.rizon.net:6667/srl | SQLite (0.99rc3+) | SRL Doc | Simba Doc | Extra Simba Libraries (openSSL & sqlite3)
    Quote Originally Posted by #srl
    10:45 < Toter> daphil when can get sex anyday I want
    10:45 < Toter> he is always on #SRL
    "A programmer is just a tool which converts caffeine into code"

  5. #5
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    ^ I think he was only saying that because death might not understand that single line if..then/others ( lazy) don't need a begin end. :3

  6. #6
    Join Date
    Mar 2007
    Posts
    478
    Mentioned
    4 Post(s)
    Quoted
    4 Post(s)

    Default

    Quote Originally Posted by Sex View Post
    No, you don't.
    SCAR Code:
    program New;
    var
      wat : integer;
    begin
      wat := 2;
      if wat = 0 then
        writeln('Wat is zero.')
      else if wat = 1 then
        writeln('Wat is one')
      else if wat = 2 then
        writeln('Wat is two.');
    end.
    Think thats easier to follow though. Btw great example.
    Back from the dead.....

  7. #7
    Join Date
    Oct 2009
    Location
    Stockton, CA
    Posts
    2,040
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    If you are going to nest a begin and end block, just add a begin and end under the else if; otherwise, leave out the semicolon after the line.
    Join the IRC! irc.rizon.net:6667/srl | SQLite (0.99rc3+) | SRL Doc | Simba Doc | Extra Simba Libraries (openSSL & sqlite3)
    Quote Originally Posted by #srl
    10:45 < Toter> daphil when can get sex anyday I want
    10:45 < Toter> he is always on #SRL
    "A programmer is just a tool which converts caffeine into code"

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
  •