Thursday, December 6, 2012

TextGroup App

I just finished another app that sends a text to a group of people. It didn't take long -- no where near as long as the last one. (:

Here are the components I needed for this app:
  • TextBox - this is where the user will enter the message; renamed MessageText; set the hint to "Enter a message"
  • Button - this is what the user will click after entering the message; renamed TextGroupButton; set text to "Text Group"
  • Label - this will report when the message has been sent; renamed StatusLabel; set text to "status"
  • Texting - this is the component that sends the text

To send the text, I needed to set two properties of the Texting component: the phone number and the message. Once these properties are set, I call the SendMessage function to actually send the text. This is what it will look like in Block's Editor (except the 1112222 will be replaced with an actual phone number):


Next, I'll modify the blocks to text more than one number at a time (note: in this version, the numbers are predetermined. So to choose different numbers, I would have to modify the blocks. There's a way to make the app so that the user can pick different numbers every time, but I don't know how to do that yet):


I'll reconfigure the blocks already in TextGroupButton.Click, and it'll look like this:


Now, when the TextGroupButton is clicked, the Texting1.Message property is set to the message entered by the user in MessageText. Then the foreach block begins executing. The two lines of blocks nested within the foreach will be executed three times, because there are three items in the list PhoneNumbers . The first time they are executed, the value var will hold the value "1112222", and the message will be sent to that number. As soon as the message is sent, the app will "loop up" and repeat the foreach blocks. The second time through, the value var will hold "3334444", and the message will be sent to it. On the third iteration, var will hold "5556666", and the third text will be sent out.

Next I modified the blocks so that the status label reports the last message sent. The updated TextGroupButton.Click looks like this:


This is what the final looks like:


This is what the app looks like:


I want to figure out how to make the app using the database, so that the user can pick different numbers every time they decide to use the app.

This app wasn't as complicated as the other one, but I still liked doing it..... I like knowing how things work!