Thank you for this new set of code. The results are exactly what I had in mind. It taught me a few new things such as using a function within a function.
Don’t get me wrong but isn’t it a lot of code for a (in my mind) relative simple calculation?
Maybe I got it all wrong but I experimented with my old code and some of the ideas I took from the various tips here and came to this:
function fDoorloopTijd() {
var:date vStart = $DatumIn; //theStartdate
var:date vEnd = $DatumUit; //the Enddate
var:date vLoopDate = $DatumIn; //set the start of the loop
var:num vDagen = days(vStart,vEnd); //Count the total number of days between start and enddate
var:list vSetDagen =; //variable to hold the weekdays from start to end
var:num vTeller =; //counter used for the loop
var:interval vDay = interval("24:00:00"); //used to increment the loopdate
// The routine lists the days of the week from start to finish
while(vTeller<vDagen){
vSetDagen+=vLoopDate.weekday;
vTeller+=1;
vLoopDate+=vDay;
$Doorlooptijd = vSetDagen.count_if(anItem,anItem<6); //do not count Weekenddays
};
};
I changed the vDay interval to interval(“24:00:00”), I noticed an near endless loop when I used “24:00”. Probably because with “24:00” it counted the minutes (?)
So it seems that both functions produce the right outcome and -most importantly- Tinderbox doesn’t stall by the edict when you open the document, nor does it stall during the periodic updates from the edicts.
Learned a lot