Why does my loop end after 1 iteration?

wolfuliumwolfulium Member Posts: 30
SubJobsT.SETFILTER(SubJobsT."Master Job No.", JobsT."No.");
    IF SubJobsT.FINDSET THEN BEGIN
      REPEAT
        IF SubJobsT."Job Type" = Job."Job Type"::Resource THEN BEGIN
          // do stuff
        END ELSE BEGIN
          count := count + 1;
          NewJobNo := JobNoFormat(ResourceJobNo, count);
          NewJobNo := JobNoValidation(SubJobsT, NewJobNo);
          SubJobsT.LOCKTABLE;
          SubJobsT."Parent Job No." := parentJobNo;
          SubJobsT.MODIFY;
          SubJobsT.RENAME(NewJobNo);        
       END;
      UNTIL SubJobsT.NEXT = 0;
    END;
    count := 0;

Here is a sample of the code, i cut things out that were not important.
However, I am trying to run this on a big set of jobs, and each master job has set of child jobs.
I have a group of jobs (96) that are all items (not resources) that run through this loop only one time.
It only does the first item of the list and then ends the loop.

Any suggestions?

Best Answer

Answers

  • wolfuliumwolfulium Member Posts: 30
    I actually had that in there, but the loop would just run forever. The counts should be 0-96 but currently running at 256 and increasing. It seems that after you rename it, it is adding it back into the list and is run again
  • wolfuliumwolfulium Member Posts: 30
    Alright so i added a field called "isclean" and set it to true when the record was "renamed"
    then checked to make sure the record's isclean field was false before continuing.
Sign In or Register to comment.