To be a little more helpful, perhaps something like a mutex (file-lock) is what you're looking for: https://code.jsoftware.com/wiki/User:Devon_McCormick/mutex.ijs . It does use a while loop though that might be improved by putting in a randomly-variable wait time.
On Sat, Jan 2, 2021 at 3:23 PM Devon McCormick <[email protected]> wrote: > My initial thought is "don't use a while loop". If all you're doing is > waiting for the file to be OK, what does this mean and how do you check for > it? > > On Sat, Jan 2, 2021 at 2:38 PM cilz <[email protected]> wrote: > >> Hello Guys, >> >> This is my first post on this forum and I take the opportunity of this >> question to wish you the best for this new year 2021. >> >> As a means of learning J I'm trying to implement my "standard" >> application with it. This app reads a text file and feed a database >> which I query to get various metrics. I also want to have a some data >> displayed in a terminal with an automatic update when the source file is >> modified or when the day changes. Simple, isn't it? >> >> In order to achieve this I thought to use a "while" loop with a kind of >> "wait/sleep" function like this foreign verb "6!:3". But unfortunately >> the result is not the one I expected as it looks like the display is >> locked until the loops ends. >> >> I have a question on Stackoverflow here >> >> https://stackoverflow.com/questions/65532824/j-programming-how-to-wait-fo-x-seconds-before-executing-the-next-verb >> but I'm still looking for a solution. >> >> Hence here is my question: is there any way to have a "while" loop which >> doesn't hold the entire verb ? >> >> here is my verb in pseudo code: >> >> agenda : 3 : 0 >> >> echo (something) >> >> while. (test for file ok) >> >> do. (wait for 20s) >> >> end. >> >> (update data base) >> >> agenda'' >> >> ) >> >> Any idea? >> >> Regards >> >> Eric >> >> >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm >> > > > -- > > Devon McCormick, CFA > > Quantitative Consultant > > -- Devon McCormick, CFA Quantitative Consultant ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
