3 posts were split to a new topic: Trying to adjust an old project
You could try the CloudDB, Is that what you need?
CloudDB is ai2's database in the cloud that is not stored on just one instance of the app, it is stored on everyone's instance.
If that is not what you want and you want a local database that is different for everyone's device, try TinyDB.
all of these use a key/value thing.
After spending lot of time, yesterday I completed the coding part of Tasker. Now, Tasker will do the following always.
-
If email notification recieved with keyword that start with prefix key in FAIR EMAIL, Tasker will parse complete notification and store it in text file.
-
I already have .CSV file with lot of keywords and onesignal id in the next column of it. If the keywords from notification is matched with CSV file, then Tasker will provide the row number where the keyword recived in notification is matched. This row number/index will be stored in another text file.
-
Now in mit ai2, il create an app that will parse the row/index value from that text file and collect the required data from CSV file( ie, onesignal id belongs to that row) using the row/index number.
-
This collected onesignal id will be put in a gloabal variable and a message will be triggered 'You Got A New Order'. So, the right user will get this notification.
CODE THAT I CREATED IN TASKER:
Task: Temp
Settings: Run Both Together
A1: AutoNotification Query [
Configuration: Persistency Type: Both
Notification Apps: FairEmail
Get All Fields : true
Timeout (Seconds): 20
Structure Output (JSON, etc): On ]
A2: Write File [
File: Download/CSV File Viewer/hi.txt
Text: %antextbig()
Add Newline: On ]
A3: AutoNotification Cancel [
Configuration: Id: %anid
Notification Apps: FairEmail
Package Name: %anpackage
Timeout (Seconds): 20
Structure Output (JSON, etc): On ]
A4: Read File [
File: Download/CSV File Viewer/hi.txt
To Var: %textfile
Structure Output (JSON, etc): On ]
A5: Variable Search Replace [
Variable: %textfile
Search: \bkey\w*\b
Store Matches In Array: %textkeys ]
A6: Write File [
File: Download/CSV File Viewer/antextbig an.txt
Text: %textkeys()
Add Newline: On ]
A7: Read File [
File: Download/CSV File Viewer/antextbig an.txt
To Var: %textfilewithkeys
Structure Output (JSON, etc): On ]
A8: Variable Set [
Name: %newline
To:
Structure Output (JSON, etc): On ]
A9: Variable Set [
Name: %newspace
To:
Structure Output (JSON, etc): On ]
A10: Variable Search Replace [
Variable: %textfilewithkeys
Search: ,
Replace Matches: On
Replace With: %newspace ]
A11: Variable Search Replace [
Variable: %textfilewithkeys
Search:
Replace Matches: On
Replace With: %newline ]
A12: Variable Set [
Name: %text_data
To: %textfilewithkeys
Structure Output (JSON, etc): On ]
A13: Variable Split [
Name: %text_data
Splitter: %newline ]
A14: Read File [
File: Download/CSV File Viewer/2010.csv
To Var: %csv_data
Structure Output (JSON, etc): On ]
A15: Variable Set [
Name: %to_search
To: %text_data(+/)
Structure Output (JSON, etc): On ]
A16: Stop [ ]
If [ %csv_data.Header3(#?%to_search) eq 0 ]
A17: Array Set [
Variable Array: %indexes_of_matches
Values: %csv_data.Header3(#?%to_search)
Splitter: , ]
A18: Flash [
Text: %indexes_of_matches()
Continue Task Immediately: On
Dismiss On Click: On ]
A19: Variable Search Replace [
Variable: %csv_data
Search: \Q%csv_data.Header1(%first_match),%csv_data.Header2(%first_match),%csv_data.Header3(%first_match)\E
Replace Matches: On
Replace With: $0,find ]
A20: Write File [
File: Download/CSV File Viewer/hihi.txt
Text: %indexes_of_matches()
Add Newline: On ]
A21: Text/Image Dialog [
Title: Result
Text: %csv_data
Button 1: Ok
Close After (Seconds): 120 ]
You could have done this with the notification listener extension together with itoo and avoid using csv files
I already explained earlier, that using files is a bad solution
Taifun
Even though, using files may not be a good choice, I wish to proceed in this way for-now. After completing this, I will move from files to sqlite in future. Is it necessary to use SAF if i use download folder?
My Text file will be updated regularly (maybe always) with numeric values (row number/index) like 4,7,1,8,4,9,2,5, etc.
How can I parse these data (may be using MFile or alternatively)?
Here is my suggestion without Tasker and without using csv files
.
Use the notification listener extension together with itoo to parse the notification
You have that information stored inside your app or Google Spreadsheet and do the necessary processing inside your app
Taifun
Let me strive to know the possibility.
Since my text file has data 1,3,2. i can read it and store it in a variable but how can I pick each value one after other? I know it is possible to do, but I don't know how to do it.
There will be no text file anymore
All data will be stored in your app... this could be in TinyDB or Sqlite
Taifun
Okay, how can i pick each value to perform some action for each values individually?
I tried to split the global variable data using split-text block but not succeeded when i tested using do it feature.
I guess, this is happening because mit ai2 is adding additional double quotes in between data forcefully. Let me try again. Thankyou.
Unfortunately we do not know how your data looks like
The best I can advice based on that little information you provided is to learn how to work with lists
Taifun
I modified the tasker code again to make the mit ai2 portion of the project much easier.
EVENT: FILE MODIFIED =>FILE: Download/177.txt;EVENT:Modify
CODE BELOW:
Task: TempPrecise
Settings: Run Both Together
A1: AutoNotification Query [
Configuration: Persistency Type: Both
Notification Apps: FairEmail
Get All Fields : true
Timeout (Seconds): 20
Structure Output (JSON, etc): On ]
A2: Write File [
File: Download/CSV File Viewer/hi.txt
Text: %antextbig()
Add Newline: On ]
A3: AutoNotification Cancel [
Configuration: Id: %anid
Notification Apps: FairEmail
Package Name: %anpackage (case ins)
Timeout (Seconds): 20
Structure Output (JSON, etc): On ]
A4: Read File [
File: Download/CSV File Viewer/hi.txt
To Var: %textfile
Structure Output (JSON, etc): On ]
A5: Variable Search Replace [
Variable: %textfile
Search: \bkey\w*\b
Store Matches In Array: %textkeys ]
A6: Variable Set [
Name: %GlobalTextKeys
To: %textkeys
Structure Output (JSON, etc): On ]
A7: Write File [
File: Download/CSV File Viewer/antextbig an.txt
Text: %textkeys()
Add Newline: On ]
A8: Read File [
File: Download/CSV File Viewer/antextbig an.txt
To Var: %textfilewithkeys
Structure Output (JSON, etc): On ]
A9: Variable Set [
Name: %newline
To:
Structure Output (JSON, etc): On ]
A10: Variable Set [
Name: %newspace
To:
Structure Output (JSON, etc): On ]
A11: Variable Search Replace [
Variable: %textfilewithkeys
Search: ,
Replace Matches: On
Replace With: %newspace ]
A12: Variable Search Replace [
Variable: %textfilewithkeys
Search:
Replace Matches: On
Replace With: %newline ]
A13: Variable Set [
Name: %text_data
To: %textfilewithkeys
Structure Output (JSON, etc): On ]
A14: Variable Split [
Name: %text_data
Splitter: %newline ]
A15: Read File [
File: Download/CSV File Viewer/2010.csv
To Var: %csv_data
Structure Output (JSON, etc): On ]
A16: Variable Set [
Name: %to_search
To: %text_data(+/)
Structure Output (JSON, etc): On ]
A17: Stop [ ]
If [ %csv_data.Header3(#?%to_search) eq 0 ]
A18: Array Set [
Variable Array: %indexes_of_matches
Values: %csv_data.Header3(#?%to_search)
Splitter: , ]
A19: Variable Set [
Name: %wrap
To: %indexes_of_matches(#)+1
Do Maths: On
Max Rounding Digits: 3
Structure Output (JSON, etc): On ]
A20: Variable Add [
Name: %Increment
Value: 1
Wrap Around: %wrap ]
A21: Variable Set [
Name: %Increment
To: 1
Structure Output (JSON, etc): On ]
If [ %Increment ~ 0 ]
A22: Variable Set [
Name: %next
To: %indexes_of_matches(%Increment)
Structure Output (JSON, etc): On ]
A23: Flash [
Text: %csv_data.Header3(%next)
Continue Task Immediately: On
Dismiss On Click: On ]
A24: Variable Search Replace [
Variable: %csv_data
Search: \Q%csv_data.Header1(%first_match),%csv_data.Header2(%first_match),%csv_data.Header3(%first_match)\E
Replace Matches: On
Replace With: $0,find ]
A25: Write File [
File: Download/177.txt
Text: %csv_data.Header3(%next)
Add Newline: On ]
And, the Blocks are:
Explanation:
The tasker code will run only if the text file is modified. Mit ai2 app will read the data/onesignalID/keyword from the text file and delete it. So, since the text file got modified, the tasker code will run and update the textfile with another onesignalID/keyword. The process continues.
Anyhow, I have to crosscheck if there is any possibility for errors in different situations. I may have to use clock in the blocks.
May I know the way to correct the word json?
And, can I search the word in notifications using regular expression like this \bkey\w*\b , so, if there is any word with prefix key in notification, then some task will be done?
The event offers the attributes oackageName, title and text... there is no such attribute json available
Use a regex extension...you can find them after doing a search in the extensions directory App Inventor Extensions | Pura Vida Apps
See again Notification Listener (powered by itoox-wrapper) and Itoo
Taifun
Okay, I shall correct that Json part as you explained.
I have to do one more thing in the above blocks I shared, ie, 'If no notification from Ecwid is recieved for more than 60 seconds, then run the whole blocks only once' .
If Ecwid notifications are coming within 60 seconds or at any time, then the whole blocks will run automatically with the help of Notification Listener. But, the whole blocks will not run if there is no new ecwid notification. So only, I decided to run the code only once after waiting for 60 seconds. By, doing this, the app will get the onesignal ID (that was stuck in a text file) from the text file that was stored earlier by Tasker after processing/analyzing the previous Ecwid notification.
Now both Mit ai2 app and Tasker are interconnected. If one app run then the other app will also run.
So, how can I set this 60 sec time limit?