Appending data to a text file ?

3,626 views
Skip to first unread message

Aneng

unread,
Feb 3, 2013, 7:37:36 PM2/3/13
to tas...@googlegroups.com
Hi,

I'm just getting to grips with scenes and doing some more advanced stuff with Tasker and I need to keep a text file log that is just the current date and a mileage figure.  e.g.:-

04-02-2013, 12345.
05-02-2013, 12542
06-02-2013, 12977

etc.

I've got a scene and tasks set up to input the mileage figure each day, but when I use Write File with %Date, %Mileage, it works - but only once. - i.e. the second time I run the task and input the mileage and try to write to the file, it doesn't add the new data.  The file contains only the one date and mileage figure from the first time it was run.

What am I doing wrong here ?

Many thanks !

Rich D

unread,
Feb 3, 2013, 9:15:56 PM2/3/13
to tas...@googlegroups.com

> I've got a scene and tasks set up to input the mileage figure each day, but when I use Write File with %Date, %Mileage, it works - but only once. - i.e. the second time I run the task and input the mileage and try to write to the file, it doesn't add the new data.

Make sure you have the 'append' and 'new line' checked in the 'write to file' action.

Check the run log (menu / more / run log )  to make sure the tasks are running as expected ..

Check the variables in the variables tab (or flash them) to see if they are getting updated.

Enable 'pop up errors/warnings' in menu / preferences / misc.  To check for file name errors..

If all else fails paste the tasks here .. long press task name / export / export description to clipboard...

Rich....

Rich D

unread,
Feb 3, 2013, 9:27:52 PM2/3/13
to tas...@googlegroups.com

> Enable 'pop up errors/warnings' in menu / preferences / misc.  To check for file name errors..

If you are testing from within tasker IE- using the task run button- you will need to exit tasker and restart tasker to get any pop up errors..

These errors should show up in the run log as well..

Rich....

Kev

unread,
Feb 4, 2013, 2:35:39 AM2/4/13
to tas...@googlegroups.com

Hi Rich,
Many thanks for the detailed help - it makes a big difference when someone tells you *how* to do what they're asking!

I did as you suggested and there are no errors or warnings in the run log and no popups appear, the variable gets updated ok - it all behaves perfectly, except for not updating the text file!

Here is the task;

test2 (50)
A1: Variable Clear [ Name:%Miles Pattern Matching:Off ]
A2: Show Scene [ Name:Numpad Display As:Dialog, Blur Behind Horizontal Position:100 Vertical Position:100 Show Exit Button:On Continue Task Immediately:Off ]
A3: Flash [ Text:%Miles Long:On ]
A4: Write File [ File:Mileages.csv Text:%DATE, %Miles Append:On Add Newline:On ]

Thanks again for your kind assistance.

Cheers,

Kev.

--
You received this message because you are subscribed to the Google Groups "Tasker" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tasker+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Rich D

unread,
Feb 4, 2013, 4:47:32 AM2/4/13
to tas...@googlegroups.com

> A4: Write File [ File:Mileages.csv Text:%DATE, %Miles Append:On Add Newline:On ]

I am not sure you can save to a '.csv' file have you tried a .txt?

Rich..

Kev

unread,
Feb 4, 2013, 5:09:18 AM2/4/13
to tas...@googlegroups.com

Ah Ha!  You have it again!  Another gold star Sir!  It works perfectly with .txt files.  One last thing (for now ;-) ), I've got the scene setup so it shows the unfolding value of %Miles above the numeric pad as you press each digit and you have to type quite slowly or it will miss a digit - ie it's a bit sluggish.  Is there anything I can do to speed it up, or is that just down to the phone ?

TomL

unread,
Feb 4, 2013, 5:32:16 AM2/4/13
to tas...@googlegroups.com
There's probably room for improvement in your code that handles the input events. Can you post more of your code here?

Tom

Rich D

unread,
Feb 4, 2013, 5:47:06 AM2/4/13
to tas...@googlegroups.com


> There's probably room for improvement in your code that handles the input events.  Can you post more of your code here?

Tom is correct, It should not be sluggish at all. It sounds like a problem that is inherit to the 'text edit box' were as you should  only need a 'text box'    

You may not be able to export the task For your button If you did not name the task And you probably will not be able to name the task now.  So you might have to copy it by hand.. it should only be a few actions and we only need the actions for 1 button.. ( hopefully)..

Rich D

unread,
Feb 4, 2013, 5:59:36 AM2/4/13
to tas...@googlegroups.com

Just to give you some additional help...

When I made my alpha keyboard to get the buttons as large as I could get them and save the most space  on the screen. I made the text red in one of the buttons and used the long press action of that button  as the delete key. 

For the enter and save  button I use the tap action of the text box. 

Rich....

TomL

unread,
Feb 5, 2013, 7:31:55 AM2/5/13
to tas...@googlegroups.com
Aneng, you sent me a private email (reply to author) when I think you meant to post to this group (post reply).  So that you don't have to type it again, here's your text:

==============
Hi Guys,

Certainly....  this is pretty much the scene I'm using to enter the mileage figure;
Large numeric keypad with 12 buttons on, (0-9 and a Cancel & OK button).  Each button has a 'tap' action of Variable Set, the value matching the button label (e.g. button 2 passes '2' to %Miles) with the append option set.  'Cancel' clears the %Miles variable and 'OK' destroys the scene.  There is a plain text 'text' box above the buttons displaying the current value of the %Miles variable.  That's it.  Nothing more complex than that !

I've noticed a strange behaviour tonight... if you tap in a number, say 12345, sometimes it will completely miss a digit - especially when it's a double tap on the same button, like 12344, but it will more often than not append the numbers in a different order to the button presses !!! - e.g. I type 12345 and %Miles gets the value 12435.  Only if I take it really slow - say one button press per second, does it get the sequence correct.

Any suggestions ?

Thanks again !
============

TomL

unread,
Feb 5, 2013, 7:33:40 AM2/5/13
to tas...@googlegroups.com
There's no way to identify what's going wrong from just your description of what you're doing.  

Can you package up your profiles, tasks and scenes into a project (turn off beginner mode if you haven't in prefs) and export the project to an xml file.  Attach the xml file to your reply to this group, and we might be able to see what's going on.

Tom

Rich D

unread,
Feb 5, 2013, 9:55:54 AM2/5/13
to tas...@googlegroups.com

A XML would be a big help.. however from your description it looks like you are just missing one piece to the puzzle.. in your button tasks you should have ..

A1: Variable set %MILES to 'button name'  append
A2: Element Text. ( This  action is in - scene / element text. It will set the text value of yous text box. You should use the replace text option)

You could give that a try.... 

Rich...

Rich D

unread,
Feb 5, 2013, 9:58:38 AM2/5/13
to tas...@googlegroups.com

> A2: Element Text. ( This  action is in - scene / element text. It will set the text value of yous text box. You should use the replace text option)

You should be setting the text box value to your %MILES

Aneng

unread,
Feb 6, 2013, 7:37:09 PM2/6/13
to tas...@googlegroups.com
I was in the process of exporting the task & scene to XML files as suggested and moved them over to a new project to bundle them all into one XML file, and, not ever having used projects properly before, I wanted to test that the scene still functioned in the new project, so I gave it a quick test, and it to my surprise, it's working properly - and responding fast enough (unless I go for the world typing speed record, in which case I can get it to go wrong now and again, but I can live with that !).  The only conclusion I can draw is that it must have something to do with it being the only thing in a new project.  As I say, I've never really used projects properly before and I have all of my profiles and tasks still in the default project.  I don't know how Tasker allocated resources, but I'm wondering if it divides them up equally between projects, so before, my scene was having to share resources with about ten other profiles in the default project, and now it has exclusive use of all the resources in a new project.  Would that make sense ?

Either way, it works now.   Thanks for your help.

Should I be putting each new 'job' into its own project, containing only profiles and tasks relevant to that 'job' then ?

One last thing Rich, you mentioned I should use Element Text to update the text box.  Any particular reason for this over my existing method of having it display the variable %Miles ?  I did try it, but all it did was display the button number - e,g, press '1' and it shows '1', then press '2' and it shows '2' (only 2, and not 12 as would be needed to).

Rich D

unread,
Feb 6, 2013, 8:22:45 PM2/6/13
to tas...@googlegroups.com

 As I say, I've never really used projects properly before and I have all of my profiles and tasks still in the default project.  I don't know how Tasker allocated resources, but I'm wondering if it divides them up equally between projects, so before, my scene was having to share resources with about ten other profiles in the default project, and now it has exclusive use of all the resources in a new project.  Would that make sense ?

I do not think so. I believe the projects tabs are just for organizational purposes only. Other tasks can still access scenes in different tabs, and profiles can access tasks in different tabs as well.  Putting them in a project tab should not affect the operations in anyway..

>
> Either way, it works now.   Thanks for your help.
>
> Should I be putting each new 'job' into its own project, containing only profiles and tasks relevant to that 'job' then ?

It is a good practice to stay organized and for export reasons as well..

> One last thing Rich, you mentioned I should use Element Text to update the text box.  Any particular reason for this over my existing method of having it display the variable %Miles ?  I did try it, but all it did was display the button number - e,g, press '1' and it shows '1', then press '2' and it shows '2' (only 2, and not 12 as would be needed to).

Yes. This should fix any lag, missing or incorrect order of text. I have the same actions in my keyboard scene and it never misses..

In the 'Element text' action you need to put your variable %MILES in the box labeled 'Text'   so it will update your Text box element with %MILES after you have appended the button number .. IE

Button 9-
A1: variable set %MILES to 9 append
A2: Element text --
Your scene name
Your element text box name
Position: replace existing
Text: %MILES

Rich..

Rich D

unread,
Feb 6, 2013, 8:39:24 PM2/6/13
to tas...@googlegroups.com

If after trying the the above you still have any lag or misses please feel free to attach your project and I will check it on my device ....

Rich...

Kev

unread,
Feb 6, 2013, 8:47:12 PM2/6/13
to tas...@googlegroups.com

I've attached the project as an xml file.  I'd be grateful if you could check it over.  Thanks.

On Feb 7, 2013 1:39 AM, "Rich D" <ricp...@gmail.com> wrote:

If after trying the the above you still have any lag or misses please feel free to attach your project and I will check it on my device ....

Rich...

--
Mileages.prj.xml

Rich D

unread,
Feb 6, 2013, 10:01:52 PM2/6/13
to tas...@googlegroups.com

> I've attached the project as an xml file.  I'd be grateful if you could check it over.  Thanks.

Very nice... It works perfect on my DROID 4 .  No lag and gets the numbers as fast as I can press them... (I did have to add the "element text' action to  the zero button task :) )  is it working for you now?

I am sure you will be much happier with this than any keyboard you could find on the play store...

Now your ready for your next big project .. I actually saw a recent post where a user was trying to use google tracks to get the mileage from trips into tasker. Apparently there is a app that will upload real time data from  google tracks to the web. So you would simply have to grab it from the web.   sounds interestingly complex.... 

Reply all
Reply to author
Forward
0 new messages