Turn first letter of Variable to capital letter

554 views
Skip to first unread message

Tristan Pointer

unread,
Nov 30, 2014, 9:58:14 AM11/30/14
to tas...@googlegroups.com
I'm working on a project to select the last number I rung and to save them to a contact - using a variable taken from autovoice as their name.
However, when the variable is taken from autovoice, the content is all lower case.

e.g. "john smith". 
   But that looks messy... I'd like to change that to:
"John Smith"
  Is that possible? I'm prepared to consider any solution to this.

Rich D

unread,
Nov 30, 2014, 10:03:07 AM11/30/14
to Tasker Google Groups Post
 
   But that looks messy... I'd like to change that to:
"John Smith"
  Is that possible? I'm prepared to consider any solution to this.


 
​action / variable / variable convert / to uppercase first.​
 

Tristan Pointer

unread,
Nov 30, 2014, 11:06:55 AM11/30/14
to tas...@googlegroups.com
Thank you very much Rich D! That was perfect :)

If anyone is interested - this is my finished setup. It allows me to say - ok google - "add john smith to my contacts" (or any name...) into my watch. I have a dialler on my watch, so I would dial John so he gets my number, then initiate this task.
Any suggestions for code improvements would also be appreciated :)

Profile: AV New Contact (74)
Event: AutoVoice Recognized [ Configuration:Command: "add (?<newcontactname>.+) to my contacts (regex)" ]
Enter: AV Add To Contacts (72)
A1: Perform Task [ Name:ScreenIf Priority:%priority Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: Stop:Off ] 
//ScreenIf turns my phone on and records that it was off to start with. I want to trigger this from my watch while my phone screen is off. Repitouch needs it to be on to work.
A2: Variable Set [ Name:%ConvertThis To:%newcontactname Do Maths:Off Append:Off ]
A3: Perform Task [ Name:First Word To Caps Priority:%priority Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: Stop:Off ] 
//This Task will be pasted afterwards. In short, it processes %ConvertThis into an upper case word for each word.
A4: Wait [ MS:0 Seconds:4 Minutes:0 Hours:0 Days:0 ]
A5: Launch App [ App:Phone Data: Exclude From Recent Apps:Off ]
A6: Wait [ MS:0 Seconds:2 Minutes:0 Hours:0 Days:0 ]
A7: RepetiTouch Pro [ Configuration:Action: Start Replay (using file "/storage/emulated/0/Repitouch/AddContactA") (replaying once) with hidden panel, close after action (silent) Package:com.cygery.repetitouch.pro Name:RepetiTouch Pro Timeout (Seconds):0 ] 
//This series of emulated touches opens the most recent number dialled in my phone, creates a new number for them and selects the text input box.
A8: Wait [ MS:0 Seconds:8 Minutes:0 Hours:0 Days:0 ]
A9: Type [ Text:%ConvertThis Repeat Times:1 ] 
// The name is typed in...
A10: Wait [ MS:0 Seconds:8 Minutes:0 Hours:0 Days:0 ]
A11: RepetiTouch Pro [ Configuration:Action: Start Replay (using file "/storage/emulated/0/Repitouch/AddContactB") (replaying once) with hidden panel, close after action (silent) Package:com.cygery.repetitouch.pro Name:RepetiTouch Pro Timeout (Seconds):0 ] 
//A simple click on "done".
A12: Wait [ MS:0 Seconds:8 Minutes:0 Hours:0 Days:0 ]
A13: Perform Task [ Name:ScreenIfEnd Priority:%priority Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: Stop:Off ] 
//If my screen was off top begin with, please turn it off again :)
A14: Notify [ Title:Added To Contacts Text:%ConvertThis added to contacts Icon:cust_star Number:0 Permanent:Off Priority:3 ]
//Notify who was added to contacts, so I know it got the right name.

Word conversion task:
First Word To Caps (75)
A1: Variable Set [ Name:%convertthis To:%ConvertThis Do Maths:Off Append:Off ] 
//Local variable ensures it is cleared each time I use the task.
A2: Variable Split [ Name:%convertthis Splitter: Delete Base:Off ]
A3: For [ Variable:%item Items:%convertthis() ]
A4: Variable Convert [ Name:%item Function:To Upper Case First Store Result In: ] 
//The most important bit! Thanks Rich D!
A5: If [ %converted Set ]
A6: Variable Set [ Name:%converted To:%converted%item Do Maths:Off Append:Off ] 
//Note the space after %item allows other %item 's to be added on. This leaves a space after the final run sequence though...
A7: End If 
// If there is text in %converted, then add item there!
A8: If [ %converted !Set ]
A9: Variable Set [ Name:%converted To:%item Do Maths:Off Append:Off ]
A10: End If 
// If there is no text, then we need to set %converted for the first time.. or it will type %converted. Placing this after line 5's if statement ensures the two do not overlap. I'm not up to speed on use of else in tasker yet.
A11: End For
A12: Variable Split [ Name:%converted Splitter: Delete Base:Off ] 
//Remember that trailing space? (See comment in line A6) Split the result by spaces...
A13: Variable Set [ Name:%ConvertThis To:%converted() Do Maths:Off Append:Off ] 
//The array is placed in a variable - but now %ConvertThis will be "John,Smith". The final space is not pushed as a comma. Nice :D
A14: Variable Search Replace [ Variable:%ConvertThis Search:, Ignore Case:Off Multi-Line:Off One Match Only:Off Store Matches In: Replace Matches:On Replace With: ] 
//Change those commas to a " " and we're all finished!
Reply all
Reply to author
Forward
0 new messages