1. HUGE Androidforums.com UPDATE! Learn what's new (and download the new app!)
    Dismiss Notice

Have Tasker read two files and send text messages


Last Updated:

  1. Vernon27

    Vernon27 Well-Known Member This Topic's Starter

    Joined:
    Nov 26, 2012
    Messages:
    53
    Likes Received:
    4
    Problem: I would Tasker to read two files (File1 and File2) and send text messages using the information from File2.

    Equipment: Samsung Galaxy Note 3 (SM-N900V) running Lollipop 5.0

    Software: Tasker (current version)

    Input files: File1 contains the names and cellphone #s of the contacts; File2 contains the template text messages.

    Output. I will like Tasker to read two files one contains the names and phone numbers of contacts (File1) and the other contains the template text messages (File2).

    Listed below is the Tasks that I have created so far:

    Profile: Blast Text Message (133)
    Day: The 25th of Dec
    Time: 8:00AM
    Enter: New Phone Number (57)
    A1: Variable Clear [ Name:%MYARRAY Pattern Matching:Off ]
    <Sets a count to see how many custom responses you have created>
    A2: Variable Set [ Name:%mycount To:1 Do Maths:Off Append:Off ]
    <getwords>
    A3: Read Line [ File:Tasker/Tasker Scripts/Message Blasts/Contacts - Test.txt Line:%mycount To Var:%temp ]
    A4: Variable Split [ Name:%temp Splitter:, Delete Base:Off ]
    A5: Flash [ Text:%temp Long:On ]
    <If %temp is EOF there are no more responses to get>
    A6: If [ %temp !~ EOF ]
    A7: Array Push [ Name:%MYARRAY Position:1 Value:%temp Fill Spaces:Off ]
    A8: Variable Add [ Name:%mycount Value:1 Wrap Around:0 ]
    A9: Goto [ Type:Action Label Number:1 Label:getwords ]
    A10: End If
    A11: Variable Subtract [ Name:%mycount Value:1 Wrap Around:0 ]
    A12: Flash [ Text:%temp Long:On ]
    A13: Flash [ Text:There were %mycount messages sent. Long:On ]
    A14: [X] Variable Randomize [ Name:%myrandom Min:1 Max:%mycount ]
    A15: [X] Say [ Text:%MYARRAY(%mycount) Engine:Voice:com.google.android.tts:eng-usa Stream:3 Pitch:5 Speed:5 Respect Audio Focus:On Network:Off Continue Task Immediately:Off ]
    A16: Array Clear [ Name:%MYARRAY1 ]
    A17: Variable Set [ Name:%mycount1 To:1 Do Maths:Off Append:Off ]
    <msgwords>
    A18: Read Line [ File:Tasker/Tasker Scripts/Message Blasts/Messages.txt Line:%mycount1 To Var:%tmpmsg ]
    A19: Flash [ Text:%tmpmsg Long:Off ]
    A20: If [ %tmpmsg !~ EOF ]
    A21: Array Push [ Name:%MYARRAY1 Position:1 Value:%tmpmsg Fill Spaces:Off ]
    A22: Variable Add [ Name:%mycount1 Value:1 Wrap Around:0 ]
    A23: Goto [ Type:Action Label Number:1 Label:msgwords ]
    A24: End If
    A25: Variable Subtract [ Name:%mycount1 Value:1 Wrap Around:0 ]
    A26: Flash [ Text:There were %mycount1 custom messages sent Long:Off ]

    **This is a work in progress**

    The problem I am having is that the Task works fine separately. How do I get them to work together. For example, Tasker should read File1 to get the name and phone number of the contact then read the second file to get the template message and send a message like the following:

    "Hello James, Wishing you and your loved ones a MERRY CHRISTMAS AND A HAPPY NEW YEAR!"

    File1 contains 50 contacts and File2 contains 5 different template messages.

    It would be nice if Tasker can randomly pick a template to send but when I add the Randomize variable it creates an endless looping.

    I believe I am on the right track but cannot seem to make the final connection.

    Any assistance will be greatly appreciated.

    Thanks,

    Vernon
     

    Advertisement
  2. Thom

    Thom Guides Guide

    Joined:
    Feb 16, 2011
    Messages:
    11,018
    Likes Received:
    4,458
    Perhaps this simple example will provide some insight ...

    demo (680)
    A1: Array Set [ Variable Array:%ArrayNE Values:nameA,emailA,nameB,emailB,nameC,emailC,nameD,emailD Splitter:, ]
    A2: Array Set [ Variable Array:%ArrayM Values:Sample message one.,Sample message two.,Sample message three.,Sample message four. Splitter:, ]
    A3: Variable Set [ Name:%tmpn To:7 Recurse Variables:Off Do Maths:Off Append:Off ]
    A4: Variable Set [ Name:%tmpe To:%tmpn+1 Recurse Variables:Off Do Maths:On Append:Off ]
    A5: Variable Set [ Name:%tmpm To:3 Recurse Variables:Off Do Maths:Off Append:Off ]
    A6: Flash [ Text:N%tmpn E%tmpe M%tmpm
    %ArrayNE(%tmpn) - %ArrayNE(%tmpe)
    %ArrayM(%tmpm) Long:On ]

    ... Thom
     
    Last edited: Dec 25, 2016
    #2

Share This Page

Loading...