Anke
September 24, 2020, 3:57pm
22
patel:
but you read from //
Look at my blocks:
I only read from //text.txt
because I want to get the text from the text.txt file (stored in the assets).
When I got that text, I save it in the new text.txt file in the Private dir.
(Btw, no need to add " + def". This was only an example.)
patel
September 24, 2020, 4:55pm
23
I can understand well the above blocks, but when I run the app the second time I read from // original file without changes. Why not so ?
Anke
September 25, 2020, 6:32am
24
Try this:
This way the text is only read for the first run of the app.
Then the new text.txt file is created in the Private dir and the text may be changed.
When the app is restarted or the screen is reopened the block (btReadText) will never be executed because if(TinyDB.GetValue -> firstRun)
= false.
patel
September 25, 2020, 6:42am
25
It's OK, but can you answer to my post 23 ? what do you think about my blocks ?
Anke
September 25, 2020, 7:44am
26
Please explain exactly what the goal is (what should be achieved):
Read the text file (appunti.txt) from the assets (at Screen.Initialize
?).
Save the text in the new file (appunti.txt) in the Private dir.
...
...
patel
September 25, 2020, 7:53am
27
my goal is to avoid error on first run
Read the text file (appunti.txt) from Private dir
if not exist (screen error) save the text in the new file (appunti.txt) in the Private dir.
then add text and save
Anke
September 25, 2020, 7:58am
28
Which text?
Where does the text come from since the text file does not exist on the first run?
patel
September 25, 2020, 8:01am
29
textbox text to create file
Anke
September 25, 2020, 8:09am
30
So this textbox is not empty at the first run (at Screen.Initialize)?
Post a test aia to shorten this conversation.
Anke
September 25, 2020, 8:20am
31
patel
September 25, 2020, 10:19am
32
your project runs well, but i think this attached too
APPUNTI.aia (13.3 KB)
patel
September 26, 2020, 7:57am
33
@Anke , thanks for all suggestions, the best solution for me is this
Okay, if you feel that is the best solution, you should close this topic by pressing the solution button in that post.
patel
September 26, 2020, 10:34am
35
I'm beginner, I'm waiting for comments, it's the best for me, but maybe there are some bugs I can not see.
So actually what functions do you want for your app.
And also see this :
http://ai2.appinventor.mit.edu/reference/components/storage.html#File
I see you want to create a Note App but use the functions of the text file right?
patel
September 27, 2020, 4:55am
39
You are right, but i just want to know if my approach is correct
Try my new Note App project, it might be very helpful :
NoteApp.aia (6.1 KB)
Note :
This App saves data using Component (File).
If You Get Bugs Or Errors, please let me know.
If this project is successful without any bugs or errors, I will make a topic for this
Regards,
Salman Dev
patel
September 27, 2020, 11:36am
41
Thank you for your app, but I would like to know if my approach is correct to read, edit and save a text file. I want to learn and not copy others' code