did'nt expect that doing a loop every 5 or 10 minutes would be that difficult
It isn't. The method is just this: A one-time event starts the action. The event can be a mouseclick, a card opening, anything. The one-time handler sets a "flag" variable to true, which indicates that the repetitive work should happen. It then calls the actual handler that does the work.
The working handler does something -- in your case, it gets a file and parses the content so it can put data into fields. Before it does that, it checks the flag variable to see if it should actually run, and if so, does the work and then sends a message to itself to run again in a few minutes.
After that amount of time, LC will trigger the work handler again. It checks the flag variable, and if it is true it does the work and sends the message to itself again.
This process continues until something sets the flag variable to false. That can be another mouseclick, or a closeCard, or any other event. The "stop" handler sets the flag to false, and when that happens the working handler will see it when it checks the status, and will not run any more.
You will need a start handler that sets the flag to true, a stop handler that sets the flag to false (they can be the same handler with an "if" clause if you want,) and a work handler that checks the flag and does the work. Messages are sent in multiples of milliseconds, ticks, or seconds. For a 5 minute interval you would use 60*5 seconds (300 seconds.) A ten minute interval would be 60*10 (600 seconds.) You shouldn't need a repeat loop at all, that's what the "send" command is for.
Here's the whole thing:
Code: Select all
local sWorking
on startWork
put true into sWorking
doWork
end startWork
on stopWork
put false into sWorking
end stopWork
on doWork
if sWorking = true then -- check the flag variable
put url ("file:myfile.txt") into tText -- get the text file content from disk
-- parse tText here and fill fields with data
send "doWork" to me in 600 seconds -- tell LC to trigger this handler again in 10 min
end if
end doWork
You just need to put the start and stop handlers into buttons, or trigger them some other way. And you need to write the script that parses the text and puts it into fields.