need to convert weekday abbreviations into full weekday names

95 views
Skip to first unread message

Logan Fury

unread,
Jan 31, 2020, 4:27:17 PM1/31/20
to Tasker
Hello,

I have a routine that is somehow turning the EE and E parameters into weekday abbreviations instead of the full names, and assigning the abbreviation to a variable.

I'm trying to put together a script that will restore the full names, and im trying to avoid 7 stacked variable search and replace actions.

Is there any way to search replace multiple items? ive tried comma space, comma no space, and the separator line and Tasker seems to be lookin for those comma space and line chars instead of treating them as separators.

Ive barely ever worked with arrays so I dont know how to compose this, I cant just add "day" to the ends, theres several additions I need:

day
sday
nesday
rsday
day
urday
day

can someone help please?

Thank you,

Logan

TaskFan

unread,
Jan 31, 2020, 4:45:41 PM1/31/20
to Tasker
Have you tried using EEEE instead?

TaskFan

unread,
Jan 31, 2020, 4:57:06 PM1/31/20
to Tasker
Other than that, just use "Array set" and put "%weekdays" in "Variable array" and "Monday,Tuesday,Wednesday,Thursday, Friday,Saturday,Sunday" in the "Values" field.

Then you can loop through the "%weekdays()" array, simply match the first 3 letters to exchange EEE with EEEE.

Robert Ryan

unread,
Jan 31, 2020, 5:05:42 PM1/31/20
to tas...@googlegroups.com
You can use this subroutine:


        To Long Date
        
        Abort Existing Task
        
    A1: Array Set 
        Variable Array: %short_day 
        Values: Sun,Mon,Tue,Wed,Thu,Fri,Sat 
        Splitter: , 
        
    A2: Array Set 
        Variable Array: %long_day 
        Values: Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday 
        Splitter: , 
        
    A3: Variable Set 
        Name: %index 
        To: %short_day(#?%par1) 
        Recurse Variables: Off 
        Do Maths: Off 
        Append: Off 
        Max Rounding Digits: 3 
        
    A4: Return 
        Value: %long_day(%index) 
        Stop: On 

You can call this using the Perform Task action. 

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/tasker/45ea077e-58af-445c-a560-a39d2432507f%40googlegroups.com.

Logan Fury

unread,
Jan 31, 2020, 5:15:54 PM1/31/20
to tas...@googlegroups.com
Hello TaskFan,

It's nice to meet you, thank you for the help! EEEE worked perfectly.

Just as a learning point I pushed on with the Array. I was working on a Task that populated the variables %ctconverted and %endtime with Sat 12:00AM and Sun 12:00AM.

First thing I did in a separate test Task was to establish these variables:


        Convert Full Weekday (222)
    A1: Variable Set [ Name:%ctconverted To:Sat 12:00AM Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ] 
    A2: Variable Set [ Name:%endtime To:Sun 12:00AM Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ] 
    A3: Variable Split [ Name:%ctconverted Splitter: Delete Base:Off ] 
    A4: Variable Split [ Name:%endtime Splitter: Delete Base:Off ] 
    A5: Array Set [ Variable Array:%abbrev Values:Mon,Tue,Wed,Thu,Fri,Sat,Sun Splitter:, ] 
    A6: Array Set [ Variable Array:%full Values:Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday Splitter:, ] 
    A7: Variable Set [ Name:%num To:%abbrev(#?%ctconverted1)  Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ] 
    A8: Flash [ Text:%num Long:On ] 
    A9: Wait [ MS:0 Seconds:2 Minutes:0 Hours:0 Days:0 ] 
    A10: Variable Set [ Name:%wday To:%full(6) Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ] 
    A11: Flash [ Text:%wday Long:On ] 
   
This worked but when I tried setting %wday to %full(%num) it errored. 

How do I make A10 "smart"? 

On Fri, Jan 31, 2020, 1:57 PM TaskFan <c.ha...@redefined.net> wrote:
Other than that, just use "Array set" and put "%weekdays" in "Variable array" and "Monday,Tuesday,Wednesday,Thursday, Friday,Saturday,Sunday" in the "Values" field.

Then you can loop through the "%weekdays()" array, simply match the first 3 letters to exchange EEE with EEEE.

--
You received this message because you are subscribed to a topic in the Google Groups "Tasker" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tasker/Houbr4lgPXs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tasker+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tasker/c6c15725-5a8c-4ded-9ad8-4cc69202ede6%40googlegroups.com.

Logan Fury

unread,
Jan 31, 2020, 5:26:03 PM1/31/20
to tas...@googlegroups.com
Hello Robert,

I don't see any variable being assigned to the data from the array? 

TaskFan

unread,
Jan 31, 2020, 5:44:04 PM1/31/20
to Tasker
Doh! And I just made you the task  :o

Nevermind, I like it and it's good practicing  :)

Here it is:



The array:


The for loop:


The If statement:



   :D

Logan Fury

unread,
Jan 31, 2020, 6:04:21 PM1/31/20
to tas...@googlegroups.com
That looks fascinating TaskFan!

How is action 8 created please? Ive never seen that

--
You received this message because you are subscribed to a topic in the Google Groups "Tasker" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tasker/Houbr4lgPXs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tasker+un...@googlegroups.com.

TaskFan

unread,
Jan 31, 2020, 6:22:10 PM1/31/20
to Tasker
That's an "Anchor" and let's you jump around in a task, create an artificial loop (anchor - code to be repeated - goto anchor / break out of the loop by jumping to another anchor right below the "goto anchor"), as well as using it as a comments field.

Since there is no "break" command like in PHP nor a dedicated "comment" action (just to name 2 things), you often have to hack around to make things work.

Don't get me wrong - Tasker is the best macro/scripting app for Android but it's not a real programming language (never was intended to be).

.

Logan Fury

unread,
Jan 31, 2020, 6:33:39 PM1/31/20
to tas...@googlegroups.com
Thank you :)

Next question, A8 is erroring saying no such task. I put Toast in Name and %weekday in parameter 1 was that wrong?

--
You received this message because you are subscribed to a topic in the Google Groups "Tasker" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tasker/Houbr4lgPXs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tasker+un...@googlegroups.com.

TaskFan

unread,
Jan 31, 2020, 6:39:01 PM1/31/20
to Tasker
The "Anchor" action can also jump to line numbers and reminds me of BASIC when I started "programming" a long long time ago :)))

They did away with line numbers in QBASIC though. Oh memories...

TaskFan

unread,
Jan 31, 2020, 6:49:31 PM1/31/20
to Tasker
"Toast" is just a custom task I use for outputting data when creating a task or troubleshooting one.

In this example, it would simply output "Friday".

So %weekday is your result variable for the input variable %abbreviation. I made it so that %abbreviation is case insensitive - for example:

%abbreviation = tUe

would return:

%weekday = Tuesday

Logan Fury

unread,
Jan 31, 2020, 7:03:16 PM1/31/20
to Tasker

I replaced the last line with a Flash %weekday and the return was the variable name not a value. Is something missing from your posted script?

Robert Ryan

unread,
Jan 31, 2020, 7:19:03 PM1/31/20
to tas...@googlegroups.com
The task I gave you is a subroutine, i.e. a task that is run from another task. 

Here is an example of how this would be used:

        Test
        
        Abort Existing Task
        
    A1: Variable Set 
        Name: %day 
        To: Mon 
        Recurse Variables: Off 
        Do Maths: Off 
        Append: Off 
        Max Rounding Digits: 3 
        
    A2: Perform Task 
        Name: To Long Date 
        Priority: %priority 
        Parameter 1 (%par1): %day 
        Return Value Variable: %full_day 
        Stop: Off 
        
    A3: Flash 
        Text: %full_day 
        Long: Off 

TaskFan

unread,
Jan 31, 2020, 7:21:24 PM1/31/20
to Tasker
I have had problems with the "Flash" action also, that's why I wrote a quick custom "Toast" task.

Presumably, it's either not accessing local variables from the calling task or it's simply not parsing any variables.

Try using the "Say" action for testing or convert the local %weekday variable to a global one.

Logan Fury

unread,
Feb 2, 2020, 5:30:34 PM2/2/20
to Tasker
I have this downloaded and imported and it's working flawlessly thank you!
To unsubscribe from this group and stop receiving emails from it, send an email to tas...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages