Execution halts without user prompt
Posted: Thu Feb 28, 2013 8:56 pm
I'm pretty excited about Livecode. I'm not far from completing my App and I've never programmed anything before. The examples and tutorials are very thorough which helps a lot.
However I have a problem I just can't solve, I'm sure there is a simple answer.
I have a card that essentially gathers information including taking a photo and then puts it all into an email to send. My code works great and I'm happy with it except that without a user prompt just before "iphoneComposeMail tSubject, tTo,,, tBody, tAttachment", the execution just freezes and the email doesn't generate. If I add in: answer "Email the report?" with "Yes" or "No" just before the iphoneComposeMail line, then regardless of what is answered the email is created and all is good. As soon as I comment out the user prompt the code freezes? The thing is I would rather not have this extra user prompt.
code: (line needed for code to execute properly is in red)
on mouseUp
--first we put the sensor readings for lat, long, time into variables
put mobileSensorReading("Location",true) into tLocation
put tLocation["latitude"] into tLat
put tLocation["longitude"] into tLong
put tLocation["timestamp"] into tStamp
--then we convert the time in seconds to date and time
convert tStamp to short date and long time
--now we ask the user to describe the place and hazard
ask "What is the hazard?"
put it into tHazard
ask "Location of the hazard?"
put it into tPlace
--now we get a photo
set the lockloc of the templateimage to true
set the width of the templateimage to "320"
set the height of the templateimage to "320"
set the left of the templateimage to "165"
set the top of the templateimage to "377"
mobilepickphoto "library"
put the last image into tAttachment["data"]
put "hazard.jpg" into tAttachment["name"]
--now we create our fields for the email send
put "sample@sample.com" into tTo
put "Test Report" into tSubject
put "The following has been reported: " && tHazard && "at" && tPlace into tHazard2
put tHazard2 && " LATITUDE:" && tLat && " LONGITUDE:" && tLong && " DATE/TIME:" && tStamp into tBody
-- now we send the email
answer "Email the report?" with "Yes" or "No"
iphoneComposeMail tSubject, tTo,,, tBody, tAttachment
put the result into tresult
switch tresult
case "failed"
answer information "Email not sent. Please try again!"
break
case "saved"
answer information "Email saved as draft. Please send."
break
case "cancel"
answer information "Operation cancelled. Report not sent."
break
default
--now we populate the data box
put tBody into fld "Body"
end switch
end mouseUp
However I have a problem I just can't solve, I'm sure there is a simple answer.
I have a card that essentially gathers information including taking a photo and then puts it all into an email to send. My code works great and I'm happy with it except that without a user prompt just before "iphoneComposeMail tSubject, tTo,,, tBody, tAttachment", the execution just freezes and the email doesn't generate. If I add in: answer "Email the report?" with "Yes" or "No" just before the iphoneComposeMail line, then regardless of what is answered the email is created and all is good. As soon as I comment out the user prompt the code freezes? The thing is I would rather not have this extra user prompt.
code: (line needed for code to execute properly is in red)
on mouseUp
--first we put the sensor readings for lat, long, time into variables
put mobileSensorReading("Location",true) into tLocation
put tLocation["latitude"] into tLat
put tLocation["longitude"] into tLong
put tLocation["timestamp"] into tStamp
--then we convert the time in seconds to date and time
convert tStamp to short date and long time
--now we ask the user to describe the place and hazard
ask "What is the hazard?"
put it into tHazard
ask "Location of the hazard?"
put it into tPlace
--now we get a photo
set the lockloc of the templateimage to true
set the width of the templateimage to "320"
set the height of the templateimage to "320"
set the left of the templateimage to "165"
set the top of the templateimage to "377"
mobilepickphoto "library"
put the last image into tAttachment["data"]
put "hazard.jpg" into tAttachment["name"]
--now we create our fields for the email send
put "sample@sample.com" into tTo
put "Test Report" into tSubject
put "The following has been reported: " && tHazard && "at" && tPlace into tHazard2
put tHazard2 && " LATITUDE:" && tLat && " LONGITUDE:" && tLong && " DATE/TIME:" && tStamp into tBody
-- now we send the email
answer "Email the report?" with "Yes" or "No"
iphoneComposeMail tSubject, tTo,,, tBody, tAttachment
put the result into tresult
switch tresult
case "failed"
answer information "Email not sent. Please try again!"
break
case "saved"
answer information "Email saved as draft. Please send."
break
case "cancel"
answer information "Operation cancelled. Report not sent."
break
default
--now we populate the data box
put tBody into fld "Body"
end switch
end mouseUp