Time for action – making the location card work

The Location card has three fields in it for latitude, longitude, and a title for the location. The user could type in the details manually, but if they happen to be at the location in question, there's a button there that will grab the location and fill in the numbers automatically. The following steps will guide you in making the location card work:

  1. Edit the script of the Set to Current Location button and type in the following lines of code:
    on mouseUp
      mobileStartTrackingSensor "location", true
      put mobileSensorReading("location", false) into tLocation
      mobileStopTrackingSensor "location"
      set the itemdelimiter to comma
      if the number of items in tLocation = 3 then
        put item 1 of tLocation into field "latitude"
        put item 2 of tLocation into field "longitude"
      end if
    end mouseUp
  2. Nothing too tricky here; we just captured the location and stored the latitude and longitude entries in the two fields.
  3. Edit the script of the Cancel button and change it to the following easy script:
    on mouseUp
      go to card "home"
    end mouseUp
  4. For the last item for this card, edit the Add Location button script and type in the following code:
    on mouseUp
      global gReminderData
      if field "location name" is empty then
        answer "Please enter a name for this location."
        exit mouseUp
      end if
      if field "latitude" is empty or field "longitude" is empty then
        answer "Please enter location values, or press the 'Set to Current Location' button."
        exit mouseUp
      end if
      put "Location" & tab & field "location name" & tab & field "latitude" & tab & field "longitude" into tLocationDetails
      if gReminderData = "no entries yet" then
        put tLocationDetails into gReminderData
      else
        put return & tLocationDetails after gReminderData
      end if
      go to card "home"
      showdata
      writedata
    end mouseUp

    Most of the handler just checks whether the user entered the required information.

What just happened?

A lot less has happened than what happened on the first card! However, it was important all the same. Now, we have a way where the user can set up a location to be used by the reminders that they have created. That's where we're headed now…

The reminder entry form

This last card is essentially an entry form; we just want to ask the user what the reminder is for. There are some tricky aspects to it though and one or two lengthy functions to cope with that.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset