I'm still not getting the reason for writing to and then reading from a file (or why the file is being written to a subfolder of where pictures are normally stored). Bob is right though, in that the consecutive if statements are problematic, but you could fix this by replacing A5 & A6 with an Else statement. But another problem I see is that the profile won't be triggered at all if Bob calls, then I call, then Bob calls, all in a 5 minute span, since when Bob calls the second time, the previous caller would be me.
I would use two arrays - one for recent caller numbers, and one for recent (incoming) call times. With each incoming call, check the recent call times and remove any array elements older than 5 minutes. Then check to see if the current caller number exists in the array. If so, start your alerting sequence. But if you're almost there, or have already gotten it to work, I would stick with what youhave.
Now that I think about it you are right that 2 people calling one after another like that would break this. Which is exactly why I was making this, as a profile I saw on the wiki (I think) didn't seem to address that. Hmm, that wonderful moment when you realize you wasted a bunch of time, I was due for one I suppose. Confusing myself with arrays it is.
Although uncle mikes suggestion is probably the preferred and most elegant here is another to ponder....
You could make a file with the file name being the missed call number and put the value of %TIMES in the file.
So at the beginning of the task you would do a files list action of the containing folder and check to see if the current call number is in that list. If it is not in the list then end task. Else test the contents of that file against the current %TIMES. If it is within the 5 min then do stuff if it is not then set the current %TIMES to that file.
Rich...
>
> And Rich, that sounds like it will be much easier to implement for me
I have used this technique in another profile that tracks my location and it works great. Once you use the 'file list' action you will see how easy and fast it is to search file names. My first thought was to not even worry about deleting the files as I do not think you would get enough different numbers that call to worry about memory space. If you do delete the directory I would think you might just delete it daily though. My original post had some flaws in the flow so here is a edited version of my thoughts.
So at the beginning of the task you would do a files list action of the containing folder. The 'file list' action has a search feature so you can match the number easily and check to see if the current call number is in that directory.
If it is not in the list then save a file with the current number as the filename and store %TIMES as the data and end task.
Else test the contents of that file against the current %TIMES. If it is within the 5 min then do stuff if it is not then set the current %TIMES to that file.
Something along those lines anyway....
Please note you will need to use %TIMES not %TIME for your time checks and do your maths in seconds.
@ Bob... nice work on the call numbers. That is good to know....:)
One more tip if you go with the above technique.
Watch for file name errors. They can be a little troublesome, you can turn on pop up errors in tasker preferences but be aware that if you are testing within tasker IE the run button.. you will not see the errors until you exit and reopen tasker. You might have to trim off white spaces at the end of the filename, illegal characters, etc.......
I would assume with a simple string of numbers you will not have any issues...
Rich..
> Rich, do you think you could upload a description or an xml of that tracking profile? I think it would help me understand how to use "file list" better to see it in action. And that sounds like a pretty useful profile anyways, would be nice to see where I've been all week for work.
Sure.. There is a lot in there and you will probably have to change some of the %WIN values in the 'Map Overlay' profile context if you want to get it working on your device.
There are 2 projects. One is the tracking profile with the display scenes And the other is a date picker that works in conjunction with the tracking profile. It is still a work in progress but it is working.
There may be other differences in the devices that could cause trouble such as proper file paths.
They should be imported as projects ..
Here ya go....
Rich...
There is a task called ' Start Loc Scene ' in the location project. This starts the viewer. Just use a task cut from your home screen to start it.
I create and write to the files in the "Get Location" task and access them in the 'Next Day' task.
Oooops, I just realized that I do not use the 'List Files' action in this project.
I just use the date as the file name..
It is My picture folder app that uses the 'list files' action. I will post that task for a example. Sorry for the confusion..... :(
OK..... I am not sure if you will be able to decipher this but here it is. This is a task that searches a list of picture folders. It works with a 'Text input Box ' element. And refines the search with each additional character entered into the text box. So if a 'A" is entered then it will find all folders that start with 'A' then if a 'N' is added then it will find all folders that begin with 'AN' but if a 'T' is added now it will find all folders that have 'ANT' anywhere in the file name. So after 3 characters It searches for the search sting anywhere in the folder name. It will also put the list in alphabetical order.
File Sort Scence2 (296)
Abort Existing Task
<lastloop>
A1: Anchor
A2: Array Clear [ Name:%fileslista ]
A3: Variable Clear [ Name:%fileslista Pattern Matching:Off ]
A4: Variable Clear [ Name:%skipretest Pattern Matching:Off ]
A5: Variable Clear [ Name:%search Pattern Matching:Off ]
A6: Perform Task [ Name:Pic File Tap2 Stop:Off Priority:9 Parameter 1 (%par1):%new_val Parameter 2 (%par2): Return Value Variable:%search ]
A7: Variable Convert [ Name:%search Function:To Lower Case Store Result In: ]
<taploop>
A8: Array Clear [ Name:%arr ]
A9: Variable Clear [ Name:%arr Pattern Matching:Off ]
A10: Variable Clear [ Name:%Fileslist Pattern Matching:Off ]
A11: Variable Set [ Name:%search To:%par1 Do Maths:Off Append:Off ] If [ %par2 ~ on ]
A12: Variable Set [ Name:%skipretest To:1 Do Maths:Off Append:Off ] If [ %search ~ . ]
A13: Variable Set [ Name:%search To:+ Do Maths:Off Append:Off ] If [ %search ~ . ]
A14: Goto [ Type:Action Label Number:1 Label:skip stop ] If [ %par2 ~ on ]
A15: Stop [ With Error:Off Task: ] If [ %new_val ~ *new_val* ]
<skip stop>
A16: Test [ Type:Variable Length Data:%search Store Result In:%varlength ]
<start loop>
A17: Variable Clear [ Name:%xxx Pattern Matching:Off ]
A18: List Files [ Dir:%Filepath Match:%search* Include Hidden Files:Off Variable:%fileslista Continue Task After Error:On ] If [ %varlength < 3 ]
A19: List Files [ Dir:%Allpicspath Match:*%search* Include Hidden Files:Off Variable:%fileslista ] If [ %varlength > 2 ]
A20: Variable Set [ Name:%fileslista To:%fileslista(:) Do Maths:Off Append:Off ]
A21: Variable Set [ Name:%Afilelist To:%fileslista Do Maths:Off Append:Off ]
<trim list>
A22: Variable Search Replace [ Variable:%fileslista Search:%Allpicspath/ Ignore Case:On Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A23: Variable Set [ Name:%Afile To:%fileslista Do Maths:Off Append:Off ]
A24: Stop [ With Error:Off Task: ] If [ %fileslista ~ *fileslista* ]
<alphabetize>
A25: JavaScriptlet [ Code:var arr = [];
arr = fileslista.split( "," );
arr.sort(function (a, b) { return a.toLowerCase().localeCompare(b.toLowerCase()); }); Libraries: Auto Exit:On Timeout (Seconds):45 ] If [ %skipretest = 1 ]
A26: Variable Set [ Name:%Fileslist To:%fileslista Do Maths:Off Append:Off ] If [ %skipretest ! Set ]
A27: Variable Set [ Name:%Fileslist To:%arr(:) Do Maths:Off Append:Off ] If [ %skipretest = 1 ]
A28: Array Clear [ Name:%arr ]
A29: Variable Clear [ Name:%arr Pattern Matching:Off ]
A30: Variable Clear [ Name:%fileslista Pattern Matching:Off ]
A31: Array Clear [ Name:%fileslista ]
A32: Stop [ With Error:Off Task:File Sort Scence2 ] If [ %skipretest = 1 ]
<end>
A33: Stop [ With Error:Off Task: ]
> I'm curious, I see you use the Task > Anchor. This is a relatively new addition to Tasker and I didn't see any description of it. I suspect it was added to aid in using Goto actions so that you don't have to worry as much about adding or removing actions. Is that right?
Actually I think the main request for anchor was for just a non functional label for organization but pent could not bring himself to make a non functional action so he made it a anchor for the goto statement.
>
> Any chance you would share the XML files? It would sure save a lot of typing er... tapping ;>)
>
Sure but this is a big fairly big one as well. I tried to make a app out out of it to share but found way to many problems trying to make it run on multiple devices. Actually the reason it got so bloated was trying to make a user friendly app for multiple devices. The original one that ran on just my device was far less bloated.
> Thanks for sharing this!
> Your posts are really helping me learn the finer points of how to use Tasker.
Your welcome. They are not the best examples by any means as I started with zero programming or development Skills.
Rich..
The task that starts the camera app is " Camera Notify Click On2"
Rich...
One more note.... I do not have much experience with sharing XML's so I'm not sure if variable values carry over with the XML. But to get the setup portion of the application to run and setup on your device the variable %Initialized needs to be cleared.
> Thanks Rich!
Glad to help..
>
> I never thought you could do so much in a Tasker app.
> Definitely an eye opener for me.
>
Let me now if you get them working and if you have any questions.
The camera folders app should work and has a help file that will hopefully explain most of it.
The location app is more personalized and as stated before will most likely need some tweeking to run on a different device. If you get the scene up and going the top middle text box with the date in it is a button that should bring up the date picker. The date picker still has a few qwerks but works for the most part.
Rich...
Glad you got it working...
>
> Profile: 2 Missed Calls = Notify (230)
> Event: Missed Call [ Caller:* ]
> Enter: Anon (231)
> A1: Load App [ App:Phone Data: Exclude From Recent Apps:Off ]
> A2: Wait [ MS:1 Seconds:0 Minutes:0 Hours:0 Days:0 ]
> A3: Kill App [ App:Phone Use Root:On ]
I am assuming you are able to clear the missed call notification with this correct?
> A4: Notify [ Title:DND - Missed Call Text:Missed Call >>> %CNAME - %CNUM Icon:hd_aaa_ext_phone_missed Number:0 Permanent:Off Priority:1 ]
Then set your own notification
All looks good to me. The only problem that might never come up would be if....
1. Bob calls for first time
2. 10 minutes passes
3. Bob calls again. // bob's file is now deleted
4. 2 minutes passes
5. Bob calls again. // you will not get your 'better be emergency ' notify
A few options would be..
1. Do not delete file just replace the data with the current %TIMES. As stated before I do not think the accumulation of files would be a issue..
2. Delete entire containing folder when the profile is not in use.
3. Enjoy your hard work and do not worry about bob calling 3 times. Why the heck is he calling so much any way...
Nice work... :)
After thinking about it you might want to address this problem because you will have this issue..
> 1. Bob calls for first time
> 2. 10 minutes passes **or any amount of time more than 5 minutes **
> 3. Bob calls again. // bob's file is now deleted
> 4. 2 minutes passes
> 5. Bob calls again. // you will not get your 'better be emergency ' notify
This seems more likely to happen then I first thought..
> The only action that uses root on this is "Kill App". Some phones can kill the apps without using root but mine can't. It's not even really necessary though, just loading the dialer app should be enough to clear the missed call notification
+1
I would load the dialer then use a go home action to stop the dialer..
> Rich D
> Thanks again for posting your File Sort Science2 task in here.
No problem... as is evident by the task name itself I have been planning on going back through it an cleaning it up and making a bit more elegant but as usually it is working so I have not bothered. I am sure there are things that can be done more efficiently ... Feel free to ask, hopefully I can remember what I did and answer....
I was working on a entirely new menu set up up but have not been able to get back and finish it...
Rich..
As for your "Sort Science" I'm getting confused seeing how %par2 gets set to "on" to match some of your if statements.
I will have to check the code but where you might be getting stuck is %par1 and %par2 are tasker variables that are used to pass data when using the 'perform task' action. So these would only be set when I was running the task from another task.
And also for when %search is set "." Is the period some sort of wildcard or pattern matching thing?
Again I will check and get back to you but I am pretty sure I needed to set the "." To a variable to use it in a search for a reason I can not recall right now..
It may be easier for me to help if you pasted the task here and inserted edits where you have questions..
Also for your menu elements, do you have a hard time getting the spacing correct on the items it lists? I can't for the life of me get the items close together.
Ahhh, welcome to the wonderful word of scenes, where your patience will be tested and re-tested and then tested again ...
Do you mean the space in between the items or the height of the item box?
Making the text very small, setting vertical spacing to 0, and changing the little menu scene edit thing to as slim as it can be without cutting off letters, after all of that if I made the menu the full height of the screen I would get maybe 6 items before having to scroll. And with this scene I need to use only half of the screen so looking at 2/3 at a time is not ideal.
>
Maybe a screen shot with a description of what you are trying to change would help.
Rich...
OK, I checked the code.. when I get a chance I will post a description of how the task works but for now..
> As for your "Sort Science" I'm getting confused seeing how %par2 gets set to "on" to match some of your if statements.
%par2 is getting set by the "search" button in the scene. This button was to manually force a search but i found I did not need it after I made a work around for the text edit box which I. Will explain in the next post..
>
> And also for when %search is set "." Is the period some sort of wildcard or pattern matching thing?
>
Disregard what I said in the last post.. the "." Is a wild card. You enter this on the text edit box to get a full list of the all files.....
Have you been able to get the entire project working and been able to view the help file?
OK. Here we go... all info refers to the above actions..
File Sort Scence2 (296)
Abort Existing Task
The about existing is important, every time there is a entry in the text edit box you want the task to start over.
<lastloop>
A1: Anchor
A2: Array Clear [ Name:%fileslista ]
A3: Variable Clear [ Name:%fileslista Pattern Matching:Off ]
A4: Variable Clear [ Name:%skipretest Pattern Matching:Off ]
A5: Variable Clear [ Name:%search Pattern Matching:Off ]
A6: Perform Task [ Name:Pic File Tap2 Stop:Off Priority:9 Parameter 1 (%par1):%new_val Parameter 2 (%par2): Return Value Variable:%search ]
This is a 'text edit box' element' work around I came up with.. I found that it would not catch all the input just using %new_val if you typed fast. So this solved the problem. I am not sure why I set %par1 to %new_val It does not seem to do any thing but the task 'Pic file tap' simply reads the value of the text edit box and returns it so now %search is set to the value of the text edit box.
A7: Variable Convert [ Name:%search Function:To Lower Case Store Result In: ]
This makes everything lower case so matching is easier..
<taploop>
A8: Array Clear [ Name:%arr ]
A9: Variable Clear [ Name:%arr Pattern Matching:Off ]
A10: Variable Clear [ Name:%Fileslist Pattern Matching:Off ]
A11: Variable Set [ Name:%search To:%par1 Do Maths:Off Append:Off ] If [ %par2 ~ on ]
%par2 is the variable from a perform task action from the 'Search' button task in the 'file browser2' scene. I put this button in so you could force a search because before I had the text edit box work around this would let you get the value of the text edit box and search for that. This will only be true if this task is called from the search button task.
A12: Variable Set [ Name:%skipretest To:1 Do Maths:Off Append:Off ] If [ %search ~ . ]
A13: Variable Set [ Name:%search To:+ Do Maths:Off Append:Off ] If [ %search ~ . ]
These 2 actions test to see if a "." Has been entered in the text edit box. I use this as a wild card to get all of the folder names. That is what the "+" will do when used as a search parameter.
A14: Goto [ Type:Action Label Number:1 Label:skip stop ] If [ %par2 ~ on ]
Skip the next action if the search button has been pressed
A15: Stop [ With Error:Off Task: ] If [ %new_val ~ *new_val* ]
Stop the task if %new_val has not been set.
<skip stop>
A16: Test [ Type:Variable Length Data:%search Store Result In:%varlength ]
<start loop>
A17: Variable Clear [ Name:%xxx Pattern Matching:Off ]
You might see this a few times throughout theses tasks. This was my way of making a anchor action before pent made that available. It is only to make a place for the goto action.
A18: List Files [ Dir:%Filepath Match:%search* Include Hidden Files:Off Variable:%fileslista Continue Task After Error:On ] If [ %varlength < 3 ]
This will get the list of folder names who's first 2 letters match the search criteria. IE if the first letter entered is "c" it will get all names beginning with "c" then if the next letter Is "a" it will find names beginning with "ca"
Now if a "t" is entered the following action will find all names that contain
The letters "cat" any where in the name. And puts the names in the array %filelista
A19: List Files [ Dir:%Allpicspath Match:*%search* Include Hidden Files:Off Variable:%fileslista ] If [ %varlength > 2 ]
A20: Variable Set [ Name:%fileslista To:%fileslista(:) Do Maths:Off Append:Off ]
Sets the variable %filelista to a comma separated list of all the array elements of the array %filelista created by A18 or A19
A21: Variable Set [ Name:%Afilelist To:%fileslista Do Maths:Off Append:Off ]
Just makes a global variable for the list. I think was just for test purposes
<trim list>
A22: Variable Search Replace [ Variable:%fileslista Search:%Allpicspath/ Ignore Case:On Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
Trims the names to remove the file path information
A23: Variable Set [ Name:%Afile To:%fileslista Do Maths:Off Append:Off ]
Again, I think this was for testing.
A24: Stop [ With Error:Off Task: ] If [ %fileslista ~ *fileslista* ]
Stops if %filelista is not set
<alphabetize>
A25: JavaScriptlet [ Code:var arr = [];
arr = fileslista.split( "," );
arr.sort(function (a, b) { return a.toLowerCase().localeCompare(b.toLowerCase()); }); Libraries: Auto Exit:On Timeout (Seconds):45 ] If [ %skipretest = 1 ]
Alphabetizes the list if a "." Was entered. The JavaScript stores the alphabetized list in a local variable %arr
A26: Variable Set [ Name:%Fileslist To:%fileslista Do Maths:Off Append:Off ] If [ %skipretest ! Set ]
Sets a global variable to the current list to be used in the menu element of the file browser2 scene. This is the list that is displayed in the menu.
A27: Variable Set [ Name:%Fileslist To:%arr(:) Do Maths:Off Append:Off ] If [ %skipretest = 1 ]
Sets the global variable to the alphabetized list of all the folder names.
A28: Array Clear [ Name:%arr ]
A29: Variable Clear [ Name:%arr Pattern Matching:Off ]
A30: Variable Clear [ Name:%fileslista Pattern Matching:Off ]
A31: Array Clear [ Name:%fileslista ]
A32: Stop [ With Error:Off Task:File Sort Scence2 ] If [ %skipretest = 1 ]
<end>
A33: Stop [ With Error:Off Task: ]
These 2 seem to do the same thing and probably are not even necessary ..
Let me know if you have any questions... Rich...
Oooops... Edit....
> <start loop>
> A17: Variable Clear [ Name:%xxx Pattern Matching:Off ]
>
> You might see this a few times throughout theses tasks. This was my way of making a anchor action before pent made that available. It is only to make a place for the goto action.
There does not seem to be a goto for this but I still used this as a way to make a label for organization. The variable %xxx does nothing. Simply a way to put a label in the task...
Rich..
> OK. Here we go... all info refers to the above actions..
>
> File Sort Scence2 (296)
I forgot to say what activates this task for others..
This is a task from a 'text edit box' element in a scene. So every time a character is entered into the 'text edit box' this task will run..
@ Mike, you never answered this question ..
Have you been able to get the entire project working and been able to view the help file?
> I have found a "bug" that is holding me up though. It seems that "Variable Search Replace" does not work on my phone/ROM
Can you post exactly what you are trying to search and replace and how you are trying it ..
Thanks, Rich..
>
> I am using a "list file" to populate %arr with the files I want to search through. When flashing %arr() I get a comma separated list of all files with their directory path as expected, ie. /storage/sdcard0/Tasker/ClientLog/filenamehere,/storage/sdcard0/...........
> I set up the Variable Search Replace like this:
>
> Variable: %arr
At first glance it looks like you need to set %arr to %arr(:) this will set the variable %arr to the comma separated list of all the elements in the array %arr
---- I tried using %arr()
That should not work
>
> Just tried %arr(:) and got the same toast message "Error: %arr(:): must be a variable or array name."
I think you misunderstood ..
You have an array %arr with all of you file names in it EI
%arr1 = "the first file name"
%arr2 = "the second file name"
Etc....
Now you need to put this into a comma separated list to be used in the variable search and replace.
It is important to understand that the variable %arr does not contain anything at this point.. It has nothing to do with the array %arr you need to set it. So use a variable set.. IE..
Variable set %arr to %arr(:)
Now the variable %arr contains "the first file name,the second file name,etc....")
Now you can use the variable %arr in your find and replace...
A technique I use when dealing with this sort of thing is use all global variables and arrays. Then after you run the task you can check in the variables tab to see what everything is set to. It is a lot easier and more accurate than trying to see everything in a flash action. Then once it is all working go back and change them to local variables and arrays.
Rich..
BTW..
A technique I use when dealing with this sort of thing is use all global variables and arrays. Then after you run the task you can check in the variables tab to see what everything is set to. It is a lot easier and more accurate than trying to see everything in a flash action. Then once it is all working go back and change them to local variables and arrays.
I found the best way to do this is simply put a "A" at the beginning of every variable and array. Now all of your test variables will be displayed first and in one area of the variable list. Then when everything works just go back through and delete the "A" from all of the variables and arrays.. and you can easily delete the global variables from the list...
Rich..
> Just tried %arr(:) and got the same toast message "Error: %arr(:): must be a variable or array name."
After rereading the post I think I see where the confusion might be. The normal way to make an array would be to do a variable split. So if you were to split a variable %test that had a value of "a,b,c," and you did not check the " delete base " option in the variable spit you would end up with an array like this..
%test1=a
%test2=b
%test3=c
AND you would still have the variable %test that still equaled "a,b,c"
However your array %arr is getting set with the files list action so the variable %arr has never been set so you need to set it...
Rich...
Thanks a million man, really appreciate you taking the time to explain things.
No problem... glad you got it going..
> I would post the set-up here but it is somewhat pointless until I put together the second half, which is now in the works since this part is pretty much all set.
>
I never asked... just curious, what are you working on?
Rich...
> This works okay but it would be nice to have this automated. I haven't figured out how to input text in a website through Tasker yet though.
I have not had to input or receive data from the web yet but i know it can be done. Actually I think the beginners guide from Pocketables has a lot on http get. Not sure about the http post though.
Sounds like a interesting project.. So far the few apps I have built with tasker have turned out far better than the apps they replaced, allowing me much more customization. So I am sure it will be worth your efforts..
Not sure if I can help much with the web stuff so you might want to post specific questions on new posts if get stuck with that..
Feel free to ask If you have more questions about the apps I posted..
Rich..