Results 1 to 7 of 7

Thread: Skipping values in For-to-do

  1. #1
    Join Date
    Oct 2006
    Posts
    468
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Skipping values in For-to-do

    I'm trying to make a For-To-Do loops that has an if-then statement at the beginning where if the if-then statement is met, it will skip to the next value in the For-To-Do loop. Like

    Code:
    for i := 0 to High(BankingPoints) do
        begin
          if(distance(a, b, BankingPoints[I].x, BankingPoints[I].y) < 10)then
             //skip to next value in for-to-do loop goes here
    I was going to just have it add 1 to I but that would then not test the new value against the if-then statement. Is what I'm trying to do possible?

  2. #2
    Join Date
    Sep 2006
    Posts
    5,219
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    Continue;

  3. #3
    Join Date
    Oct 2006
    Posts
    468
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Ah thanks. Also, is there a way to end a procedure early with a command?

  4. #4
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Break; for loops
    Exit; for procedures

  5. #5
    Join Date
    Oct 2006
    Posts
    468
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Going to bump this up a little instead of making a new thread. Is there a way to have a for-to-do loops increase by say, 0.1 rather than 1?

  6. #6
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Just divide I by 10

    SCAR Code:
    for I := 0 to 100 do
        WriteLn(FloatToStr(I / 10));
    Last edited by Wanted; 12-24-2009 at 03:35 AM.

  7. #7
    Join Date
    Sep 2006
    Posts
    5,219
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    Also sometimes these:
    Code:
    program New;
    var i:extended;
    begin
      i := 0;
      repeat
        writeln(i);
        i := i + 3;
      until i>10;
    
      i := 0;
      while i<10 do
      begin
        i := i + 2.3;
        writeln(i);
      end;
    end.

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
  •