(i go on with this thread for "scientific interest", having already solved the practical problem, thanks btw to the help of a few of you)
Roman Haefeli wrote:
I don't see, how a [delay 0] can help here. The result is still zero logical time.
I didn't expect it to make any difference either. However, compare my patch (without delay 0) and Jack's one (with delay 0) and you'll see his one works and mine doesn't.
Both do the same sequence of operations, in the same order, in 0 logical time:
the only difference being the presence or not of a zero delay after each iteration of the loop (an important difference)
This means the following message trees (pardon me if I arrange them horizontally rather than vertically but I'm not very good at ascii 'art'):
--- A: NO DELAY ---
-+- send message to create folder | +-+- loop iteration 1 (check dir exsistence) | | | +- loop iteration 2 | | .. | +- loop iteration N (dir is found or maximum # of cicles is hit) | +- write file
--- B: WITH ZERO DELAY ---
-+- send message to create folder | +-+- loop iteration 1 (check dir existence) | +- bang to [delay 0]
-+- loop iteration 2 | +- bang to [delay 0]
...
-+- loop iteration N (dir is found) | +- write file
(possibly with minor errors, I hope not any major ones)
Though in both cases it all happens it 0 time, in the first case it is all in one message tree while in the second case it's several detached message trees.
It seems like, for some reason, the directory cannot _actually_ be created untill the whole message tree (one of whose branches has provoked the sending of the message) is completed.
I can only try 2 guesses:
A) it is because of how the operating system manages processes (i.e. the "delay 0" has a similar role to a "sleep 0") - but then, I would expect an amount of unpredictability
B) because of the way PD is implemented, maybe the message is not even actually sent to the gui process until the whole message tree is completed?? or the gui is somehow aware of the fact that the message tree is not complete and won't process the messages it has received until it is????
Does this make sense?
thanks m.