Hi Eric,

I had seen your initial question on StackOverflow, attempted an answer, and I 
am glad you headed over here for more options.

It sounds to me as if you are setting up an infinite loop that waits on a 
change to the database to do an update and exit. I think that this can be done 
using the break. control word inside the while. loop. 
https://www.jsoftware.com/help/dictionary/cbreak.htm
I also think that this will lock up your J session until you have a change to 
your database and I don't think that that is what you are aiming for.

If you are working in the jQt IDE have you looked at the timer event? 
https://code.jsoftware.com/wiki/Guides/Window_Driver/Event_Handling#Timer_Events
This could initiate your code once every x seconds and in the interim allow the 
rest of the session to run.

Cheers, bob

> On Jan 2, 2021, at 13:26, cilz <[email protected]> wrote:
> 
> Hi Devon,
> 
> Thanks for trying to help me.
> 
> If there is no database when I launch the app I create a new one. This 
> database contains 2 tables. One for the data red from the text file and one 
> to store the modification time of the text file used to populate the database 
> which I get with: "tsrep (0 1 {:: 1!:0 FILEPATH)". If I don't modified the 
> text file while the app is running, its modification time is the same as the 
> one store in the database. Hence I have a verb which just do that and returns 
> 1 if it's OK and 0 if the 2 values aren't equal.
> 
> I check this in the boolean condition of the while loop of "agenda" below.
> 
> So in the verb below, I want:
> 
> 1- display something
> 
> 2- run a loop (or anything) inside which I check if the file has been updated
> 
> 3- stay in that loop if there is no update or exit if any update
> 
> 4- delete the database and create a new one
> 
> 5- call "agenda" again
> 
> I did have lisp like version of this which run perfectly, this is the reason 
> why I started to do that in J. But may be this is not the J way of doing it? 
> Should I use a "goto" instead of the loop or anything else?
> 
> So far my J implementation is really fast and gives me very good results. But 
> now I'm stuck on something I thought would be very easy...
> 
> Best
> 
> Le 02/01/2021 à 21:23, Devon McCormick a écrit :
>> 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:
>> 
>> 
>> 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

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to