Mobile contacts

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
jacobb20
Posts: 9
Joined: Mon Nov 26, 2012 4:21 pm

Mobile contacts

Post by jacobb20 » Wed Nov 28, 2012 10:43 pm

Having some trouble with mobile contacts...wondering if there are additional resources for using mobile contact functions, can't seem to get much to work.

Code: Select all

on mouseUp
   local contact_id, search, contact_ids, tContact
   put field txtSearch into search
   if the environment is "mobile" then
      # returns id
      put mobilePickContact into contact_id
      answer "contact id is: " & contact_id
      
      # search based off of text box
      if search is empty then
         answer "Please enter a search string"
      else
         put mobileFindContact (search) into contact_ids
         answer "search contact ids: " & contact_ids
      end if
      
      # show the first contact details
      mobileShowContact (contact_id)
      
      # return data about the first contact
      put mobileGetContactData (contact_id) into tContact
      if tContact is an array then
         answer tContact["firstname"]
      else
         answer "No results"
      end if
   else
      answer "Must be on a mobile device for this to work"
   end if
end mouseUp
So this is what I get as results.

1st time call:
"contact id is: mobilePickContact" ?? if I just put mobilePickContact then it does bring up a list of contacts, but how do I save that ID that they selected?

"search contact ids: 21" - this seems to work

mobileShowContact contact_id does not do anything

"No results" - should get the contact data if the above worked?

2nd time:
"contact id is: mobilePickContact"

App crashes. (on ipad)

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Mobile contacts

Post by jacque » Thu Nov 29, 2012 6:22 am

MobilePickContact is a command, so it must be all alone on a line. The item the user chooses is returned as the result, so you check that to get the actual value:

mobilePickContact
put the result into contact_id

Lots of commands return their values in "the result". The dictionary tells you which ones those are.

The way you had it originally, the actual string "mobilepickcontact" is placed into the variable because it's being used that way in the syntax. The engine shouldn't ever crash though, even if the syntax is wrong, so that's a bug.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

jacobb20
Posts: 9
Joined: Mon Nov 26, 2012 4:21 pm

Re: Mobile contacts

Post by jacobb20 » Thu Nov 29, 2012 8:43 pm

Thanks! That makes more sense.

This is consistently crashing on my ipad2 ios 6.0.1

Code: Select all

on mouseUp
   local contact_ids, search
   put field txtSearch into search
   if the environment is "mobile" then
      # search based off of text box
      if search is empty then
         answer "Please enter a search string"
      else
         mobileFindContact search
         put the result into contact_ids
         answer "search contact ids: " & contact_ids
      end if
   else
      answer "Must be on a mobile device for this to work"
   end if
end mouseUp
works first time, then it crashes on the second search.

EDIT:
works all the time unless I search for specific names?? "ben" and "mike" crash it every time, "jacob" does not.

jacobb20
Posts: 9
Joined: Mon Nov 26, 2012 4:21 pm

Re: Mobile contacts

Post by jacobb20 » Fri Nov 30, 2012 5:58 pm

anybody? is there a way to test why it crashes? Can I somehow display the error message?

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Mobile contacts

Post by jacque » Fri Nov 30, 2012 7:03 pm

Wrap the command in a "try" statement and if it fails, put the error into an answer dialog:

Code: Select all

try
  mobileFindContact search
  put the result into contact_ids
catch tErr
  answer tErr
end try
You don't always get an error if there's a crash so the above may not work. The engine has to do some sneaky things behind the scenes to implement the answer dialog, so that may be the problem. But it should always crash if that's the case, not just with specific names, so it's a puzzle. You could try removing the answer command entirely though and see if the crash still happens.

In any case, the problem should be reported to RR as a bug. If you aren't in the developer program you can send the report to bugs@runrev.com and they will enter it into the database for you. A sample stack that shows the problem should be included.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

jacobb20
Posts: 9
Joined: Mon Nov 26, 2012 4:21 pm

Re: Mobile contacts

Post by jacobb20 » Fri Nov 30, 2012 8:31 pm

Did the code you mentioned, still crashes no error message displayed.

I did add a phone # under one of my "mike" contacts and then it worked for awhile, now it doesn't. Tried "laurie" and I have one contact by that name and she does not have a phone # listed at it works for her, but its probably something weird like that. "mike" never worked until I added the phone number then it worked everytime for an hour or so, but now it doesn't again :(

It does scare me a bit that the try catch does not stop the app from crashing.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Mobile contacts

Post by jacque » Fri Nov 30, 2012 10:11 pm

I wasn't really counting on the try/catch to work. That isn't anything to be worried about, it just means the crash is happening before the rest of the handler can execute.

It sounds to me like the content of the contact info isn't too important and the crash is happening more randomly than that. If you plug the iPad into the Mac and launch XCode, there should be a crash log. When you report the problem, it would be a good idea to include that. And if you know how to read those things, it might give you a clue where things went bad. I don't think it's anything you can fix with coding.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply