Cancel
Showing results for 
Search instead for 
Did you mean: 

repeat until code issue

Valued Contributor
Valued Contributor

Dear community members,

in one method i'm trying to insert a repeat_until structure whithin an if_ then structure.

The method seems to not recognize it and breacks the if_then structure as shown in the picture.

temporaneo.PNG

As you can see, on the left there isn,t any line.

Why does it happen?

6 REPLIES

Re: repeat until code issue

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

Hi Alessandro

 

The reason the method doesn't  recognize the repeat structure is because you are missing a second end. You have created two If structures and hence you need two ends to finish them.

 

Your structure should be more like this

 

is
    k:integer;
    i:string;
    z: object;
do
    If variableWait = "Yes" then
       If nextp.nummu < 1 then
          repeat
             k:= nextlocation.getrowNo(predID.name);
             i:= nextlocation[1,k];
             z:= str_to_obj(i);
             nextp:=z;
          until nextp.nummu > 0;
       End;
    End;
    nextp.cont.move(parallelproc);
end;

 

I am not sure where you want the move to parallelproc so you might want it placed between the two Ends

 

Kind Regards

 

Ollie

Oliver MacFarlane
Simulation Engineer
web: www.simsol.co.uk
e-mail: oliver.macfarlane@simsol.co.uk

Re: repeat until code issue

Valued Contributor
Valued Contributor

Hi Oliver, 

thank you for the answer.

Actually the first "if" ends at the end of the method (I posted only a part of it). Anyway i tried to put another "end" as you suggested, but it still does not recognize it.

I attach my model in the case you could have a look into.

The method is "calledbypull".

Re: repeat until code issue

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

Hi Alessando,

 

Looking at your code there is nothing intrinsically wrong with it (I set variableWait = "yes" and saw if the code ran) and it seems to be working well (although it might run infinitely, described later on). However your code will currently never enter the repeat or while areas as your model doesn't get to variablewait = "yes". 

 

This is because there seems to be an error in the VarWait code. Specifically at the line:

 

if str_to_obj(buffnames[1,i]).nummu >= str_to_obj(buffnames[2,i]).levelingQuantity 

 

There is nothing wrong with the code itself but when you get to i=4, buffnames[2,i] is now a blank entry as you only have 3 Mus listed. Therefore buffnames[2,4] = "" and the str_to_obj is blank and an error comes up.

 

This codes work fine at beginning as you have just 3 buffers listed in buffnames but I think you add extra rows in parallelEntry code and this causes your problems above.

 

In terms of your called by calledByPull code you might get an infinite loop in the repeat and while parts of the code.

 

This is because while you are setting a different buffer with nextp:=z, if the buffer doesn't have any MUs in it then this will go on infinitely. Time stops while code is being run and therefore no MUs can enter the buffer until the code stops (or you move MUs to a buffer using move in the code). So the code will keep repeating infinitely.

 

Does that make sense?

 

Ollie

 

 

 

 

Oliver MacFarlane
Simulation Engineer
web: www.simsol.co.uk
e-mail: oliver.macfarlane@simsol.co.uk

Re: repeat until code issue

Valued Contributor
Valued Contributor
Yes, I knew all the code issue you identified. My post is exclusively on the recognition of the repeat untile in the if condistion, that my model do not recognize. Anyway I solved the model issue with another cose, but still the repeat until is not recognized. I will run more trials

Re: repeat until code issue

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

Hi Alessandro,

 

Sorry about that , I did see that Steffan had answered most of what I wrote in your other thread afterwards, so glad you got those problems sorted. 

 

If you could send your current model, I could see if the repeat works or not on my computer as not something I have come accros before.

 

Ollie

Oliver MacFarlane
Simulation Engineer
web: www.simsol.co.uk
e-mail: oliver.macfarlane@simsol.co.uk

Re: repeat until code issue

Solution Partner Valued Contributor Solution Partner Valued Contributor
Solution Partner Valued Contributor

From what I saw in the model your repeat statement would never trigger because your condition was never going to become true.

 

After tracking a bit the problem was in your VarWait method

 

You had something like:

 

if  str_to_obj(buffnames[1,i]).nummu >= str_to_obj(buffnames[2,i]).levelingQuantity then

and need something like:

 

if (buffnames[1,i]/="" and str_to_obj(buffnames[1,i]).cont/=void) and 
str_to_obj(buffnames[1,i]).nummu >= str_to_obj(buffnames[1,i]).cont.levelingQuantity then

One to prevent the error Ollie mentioned and two because the value in table buffnames[2,1] you are reading will never return the value of levelingQuantity.

 

Now after that comes the deadlock in your wait statement in the calledbypullmethod but the statement work as programmed.

 

I'm adding your model with the modifications I mentioned.

 

Regards,

 

 

 

cortega@interlatin.com.mx
+52 (81) 10801310
InterLatin S de RL de CV