Fill in a number, make a picture and send with e-mail

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
scs007
Posts: 1
Joined: Sun Jun 23, 2013 2:33 pm

Fill in a number, make a picture and send with e-mail

Post by scs007 » Sun Jun 23, 2013 2:55 pm

Hi,

I'm trying to create an app that let the user:
- fill in a number in a text entry field
then
- Capture a picture with the camera
then
Send this picture by e-mail to a predetermined e-mail address with the text entered in the 'text entry field' as a subject but with fixed text in front of the entered text. Attached to the e-mail the picture with the date and time as filename. The send from address must be from the default account of the user.

The text entry field must only accept numbers and dots.
- How can I add the dot as an accepted key?
- How can I limit the input field to max 9 characters?

Code: Select all

on keyDown theKey
      ## Check whether theKey is a number or dot
     if theKey is not a number or theKey is not a "." then
       ## If not beep to alert the user
            beep
      else
          ## If it is pass keyDown up the message path
          ## The engine will handle the message and the key will appear in the field
      pass keyDown
   end if
end keyDown
For getting the picture I placed a button in the stack with the code below. I tried combining some of the code from the video tutorial to get a picture and upload it to an FTP. But I totally screwed up.

Code: Select all

on mouseUp
  mobilePickPhoto "camera"
end mouseUp
Now I have the code I found somewhere else on the forums to send a picture by e-mail;

Code: Select all

  put tempPhoto into myData["file"]
  put "image/jpg" into myData["type"]
  put "File Name" into myData["name"]
  mobileComposeMail "My subject", , , , "My body", myData
But I'm totally lost in how to use it. Tried solving it by searching the documents and lessons I found on youtube but how to combine data into the mobileComposeMail is a total mystery for me.

To answer also a question you have after reading this; yes I'm trying to program ;-)

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Fill in a number, make a picture and send with e-mail

Post by Simon » Sun Jun 23, 2013 6:40 pm

Hi scs007,
Welcome to the forum! :)

You've pick a good project to sink your teeth into with LiveCode, much information to learn.

Starting with the field question, the problem with your code I'll call a "double negative" (I'm sure theres a mathematical reason for it but my logic isn't working this am).

Code: Select all

"if theKey is not a number or theKey is not a "." then"
that double "not" was giving you the trouble removing it:

Code: Select all

"if theKey is a number or theKey is "." then"
works fine

For the max number of characters:

Code: Select all

"if the number of characters of me < 9 then"
Pretty cool huh? Not that difficult to understand.
This assumes the on keyDown is in the Field script.

Put together:

Code: Select all

on keyDown theKey
   ## Check whether theKey is a number or dot
   if (theKey is ".") or theKey is a number then
      ## If it is pass keyDown up the message path
      ## The engine will handle the message and the key will appear in the field
      if the number of characters of me < 9 then
         pass keyDown
      end if
   else
      ## If not beep to alert the user
      beep
   end if
end keyDown
Name the above field "myNumberField" to continue with the email portion:

The Subject line:
look up "before", "after" and "into" in the LC Dictionary.

Code: Select all

on mouseUp
   mobilePickPhoto "camera"
   put last image into tempPhoto --store the photo data in a variable
   
breakpoint
   put "This is the fixed text before the field number, here comes the number> " into tSubject --your fixed text
   put field "myNumberField" of this card after tSubject --the name of your number entry field is "myNumberField" (or anything but they must match).
breakpoint
   
   put tempPhoto into myData["file"]
   put "image/jpg" into myData["type"]
   put "File Name" into myData["name"]
   mobileComposeMail tSubject, , , , "My body", myData --notice no quotes around variables
end mouseUp
Here are some great resources for you to use:
http://lessons.runrev.com/
http://www.hyperactivesw.com/revscriptc ... ences.html

Have Fun,
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Post Reply