Results 1 to 5 of 5

Thread: If...Then...Else Problems!

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

    Default If...Then...Else Problems!

    Ok, so, I have something along the lines of this:

    SCAR Code:
    Program New;
    {.include srl/srl.scar}

    Procedure One(Two : Integer);
    Begin
    //Dostuff
    End;

    Procedure Three(Four : Integer);
    Begin
    If(Four <= 7) Then
    Begin
    Wait(1000)
    One(Four);
    End else
    //Dostuff
    end;


    Begin
    SetupSrl;
    Wait(1000)
    Three(6)
    End.

    Here's my problem:

    My script decides that 6 is NOT equal to or lower then 7, and as a result it continues on with procedure Three;. I want it to proceed to procedure One;. Can anyone tell me why this is happening? Greatly appreciated .

    ~Sandstorm

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

    Default

    Works like it should for me:
    SCAR Code:
    Procedure One(Two : Integer);
    Begin
      writeln('Int is: '+inttostr(Two));
    End;

    Procedure Three(Four : Integer);
    Begin
      If(Four <= 7) Then
      Begin
        Wait(1000)
        writeln('Less or Equal to 7');
        One(Four);
      End else
       writeln('Greater then 7');
    end;


    Begin
      Wait(1000)
      Three(6)
    End.

    Successfully compiled (11472 ms)
    Less or Equal to 7
    Int is: 6
    Successfully executed
    Are you wording your question wrong? Or you getting a result you don't want?
    (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.

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

    Default

    I'm getting a result I don't want. It seems that I get the opposite of what I'm supposed to. I'll go try it again.

  4. #4
    Join Date
    Feb 2007
    Location
    Toronto, Ontario, Canada
    Posts
    586
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    Procedure Three(Four : Integer);
    Begin
    If(Four <= 7) Then
    Begin
    Wait(1000)
    One(Four);
    End else
    //Dostuff <-- this will be done conditionally
    //This will be done regardless
    end;
    If the //Dostuff after End else is more than one line, it will apply the else condition only to the first line following it, then execute the rest of the code regardless.
    Consider:
    SCAR Code:
    Procedure Three(Four : Integer);
    Begin
    If(Four <= 7) Then
    Begin
    Wait(1000)
    One(Four);
    End else
    begin
      //Dostuff
      //DoMoreStuff <-- both of these will be executed conditionally
    end;
    end;

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

    Default

    Yea, I know that . I figured out my problem.

    I actually had this:

    SCAR Code:
    If not Condition Then
    //Dostuff(this is where it skips to first procedure)
    else
    //Dootherstuff
    end;

    I needed this:

    SCAR Code:
    If not Condition Then
    exit;
    else if Condition then
    skipptofirst;
    else
    //dootherstuff
    end;

    So yea, more like my own stupidity :/.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. SQL Problems. Please help!
    By Da 0wner in forum Web Development
    Replies: 10
    Last Post: 01-22-2009, 02:03 AM
  2. Computer problems... Terrible computer problems...
    By Jason2gs in forum News and General
    Replies: 22
    Last Post: 04-26-2007, 12:02 PM

Posting Permissions

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