Good morning, I have a problem with the code, it is already assigned to each bay but in the first bays it is randomly stored and exceeds the capacity. Please, if you can help me with the program. Thank you
/**Custom Code*/ treenode item = param(1); treenode current = ownerobject(c); int cellcap = 2; int baynum; if (getitemtype(item)==1) { baynum=duniform(1,10); break; } if (getitemtype(item)==2) { baynum=duniform(11,18); } if (getitemtype(item)==3) { baynum=duniform(19,30); } if (getitemtype(item)==4) { baynum=duniform(31,50); } int flag = 2; int bays = 2; while(flag<=2) // loop limit { if(rackgetbaycontent(current,baynum) < cellcap*rackgetnroflevels(current,baynum))// enough capacity { return baynum; } else { flag++; baynum = fmod(baynum,bays)+1 + (getitemtype(item) - 1)*bays ;//find next bay } break; } return (getitemtype(item) - 1)*bays + 1; //no right bay will goto first bay of specified itemtype