File operations and conclusion

Q.1 and Q.2 are not related to each other. I ask if after the execution of procedure Q.1 the following blocks can considere it concluded. The same question is for procedure Q.2.

You could do some testing to confirm creation of directories and copying of files:

image

:question:

What is your goal?

I have to perform about twenty operations as described, in sequence. At the end I have to make sure that they are all finished. If gives me the control at the end without having finished them there is a problem. And if I need to check the end of each operation as suggested by TIMEI2 (thanks) well...become a mess.

Use lists.

If you explain in more detail what it is you are hoping to achieve, then maybe we can help to provide possible solutions.

Ciao Renato, credo che tu sia Italiano, per cui provo a dirlo in altre parole, per vedere se ho capito.
Tu fai molte (una ventina) di operazioni su files. Non stiamo parlando di problemi di permessi di scrittura o lettura, ma che il flow del programma va avanti senza essere sicuro che tutte le operazioni siano state concluse correttamente.
Se questa interpretazione è corretta, tieni presente che AI2 funziona ad eventi, differentemente da un tipo di codice "sequenziale", quindi una volta lanciata un'operazione, questa va avanti per i fatti suoi, e solo se c'è un check "asincrono" a evento concluso, sei sicuro che l'operazione sia stata svolta.
Per fare questo io solitamente (soprattutto con gli eventi correlati ai files) uso dei clock con tempi di attesa di 2 o 3 secondi, per dare tempo al sistema operativo, e quindi ad AI2, di fare le sue cose sui files e dopo vado a fare i check, tipo quelli che ha suggerito @TIMAI2.
Tieni anche presente che in AI2 non puoi mettere in "hold" il flow del programma in attesa di un evento, perché la messa in hold resta per sempre, non viene interrotta da eventi asincroni. Su questo problema ci sono molti post su come, eventualmente, implementare dei delay.
In definitiva, usa dei clock per dare tempo alle operazioni sui file di finire e quando i(l) clock scade fai le verifiche del caso.
Ciao.

Dear @Anke and @TIMAI2 , sorry for having responded in Italian, but in this way I've tried to get in touch with more details on what it could be the issue that Renato is facing with.

Grazie uskiara, si ho gi√† avuto modo di scontrarmi con tali problemi e li sto gestendo con i clock. Se devo eseguire pi√Ļ operazione che penso possano incontrare tali problemi attivo il clock che all'evento mi fa partire la prima operazione, la quale al termine incrementa un valore e ri abilita il clock. Il valore serve ad individuare quale funzione far partire, e via dicendo. Ma ci sono alcune operazioni per esempio quelle su TinyDB che pare non abbiano necessit√† del meccanismo, coma anche altri con File (forse perch√® sono velocissime?). Mentre altre invece hanno bisogno del meccanismo. Infatti nel posto ho inserito solo quelle che mi creano qualche perplessit√†. E' un po un casino per ogni operazione attivare i clock. Io provengo da altri ambienti e altri linguaggi e tutto filava liscio. Se non ti prendo troppo tempo gradirei un esempio di come gestire i controlli con le liste come suggerice TIMAI2. Grazie...ma di dove sei?

Thanks uskiara, yes I have already had the opportunity to encounter these problems and I am managing them with the clocks. If I have to perform more operations that I think may encounter such problems, I activate the clock which, upon event, starts the first operation, which at the end increases a value and re-enables the clock. The value is used to identify which function to start, and so on. But there are some operations, for example those on TinyDB, which do not seem to require the mechanism, as do others with File (perhaps because they are very fast?). While others instead need the mechanism. In fact, in the post I have only included those that cause me some doubts. It's a bit of a mess for each operation to activate the clocks. I come from other environments and other languages ‚Äč‚Äčand everything went smoothly. If I don't take up too much of your time, I would like an example of how to manage controls with lists as TIMAI2 suggests. Thanks... but where are you from?

First of all, we would just like to know what his goal actually is.
And I still don't understand that. @renato

OK, probably my english...I want to be sure that the file's request shown in the block i sent, are finished because i need to use them in the 'following blocks'. Those block are part of a procedure to prepare all needed directory and files for the app.

Dear @Anke,
the problem that Renato is facing with is the fact that the operations done on files take (their) time to be completed and the "main" program flow continues while the flie operations are still being performed (like they were executed in background) so he has to wait until those operations are finished before letting the program flow to continue.
What I've suggested him is to use clocks to allow the files operation to be completed before letting the program flow to go on.
Any more clever hint is anyway much appreciated.
Cheers, Ugo.

Dear @renato,
also my backgroound is mostly on "embedded systems" where you have a sequential program flow, and tasks are executed based on schedulers (very very rarely based on RT OS) and you have "interrupts" to manage hardware time-critical tasks.
Therefore the "on event" approach is somewhat a nightmare for people like us ... :rofl: :rofl: :rofl:
I believe that by using many clocks can lead to a mess, if not correctly managed, but in this way (though my files operations were simpler than yours) I've got it working.

(I'm from Turin)

EDIT: about the use of lists, I let @TIMAI2 to explain what he's suggesting... :thinking:

I warked years on Visual Basic so i am used to 'events'. Anyway I will try to travel into this forest of clocks and make sure it works. Thank you very much. I am from Rome.

Creating new directories shouldn't take any time. Copying (larger files) in order takes a few milliseconds, so things should be done asynchronously (i.e. one after the other). The common file extensions from @Taifun and Sunny @vknow360 both offer this option.

2 Likes

Dear @renato,
please take also a while to investigate the suggestion said by @anke.
She's got a huge experience in the "forest" of file handling on Android, and she has written lot of tutorials on the matter. You'll find them by digging the forum in the search tool.
Best wishes !

PS I also worked with VB (a life ago!) to make user interfaces of Siemens S7 PLC's and in that environment the synchronization with the HW was more strict and effective. But I'm talking about WinNT or Win95 and I was allowed to rise up the VB priority to the maximum, so probably the overall behaviour was closer to a RT ....
Per aspera ad astra (i.e. never give up !).

1 Like

A simple example, running companion it takes milliseconds to complete

1 Like

Thanks a lot TIM.
Great, as usual !!
Cheers, ugo

Edit ...recursive code: not allowed in embedded systems :rofl: :rofl: :rofl:

thanks all.
I'll close if you don't have anything against it

Dear Renato,
you can set as "solution" the answer from @Anke or @TIMAI2, whichever you'll apply.
Ciao.

Thanks TIMAI2, I'll use your example as guide line in future.
Hope you help me on some other question. Bye

As a guide for what?

Where is the problem for example with these simple blocks:

So can someone please explain to me what this is really about? :pray:
It really shouldn't be that hard.