mobileVibrate Command

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
archer2009BUSknbj
Posts: 72
Joined: Sat Apr 06, 2013 8:09 am
Location: London

mobileVibrate Command

Post by archer2009BUSknbj » Fri Jun 07, 2013 8:04 pm

I want to write n App for Android that makes my phone Vibrate

I've found the command mobileVibrate

And seen the example in the dictionary that says mobileVibrate 7 will get your phone to vibrate 7 times

But what I want to do is get my phone to Vibrate for different lengths of time - sort of like Morse Code style - long and short vibrations

like maybe vibrate 1 seconds, then 2 seconds, etc - is this possible?


Also I get an error when I run the code below (using Windows 7):


on mouseUp
beep 7
mobileVibrate 7
end mouseUp


button "Button_Beep": execution error at line 3 (Handler: can't find handler) near "mobileVibrate", char 1

What is causing the above error?
is it because I'm trying to run a command for mobile phone in Windows or something else?

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: mobileVibrate Command

Post by Mark » Sat Jun 08, 2013 11:05 am

Hi,

No, I don't think that's possible. The API that manages the vibration has only one command to make the phone vibrate. In Objective-C, you need to use arepeat loop if you want to make the phone vibrate for a long time. That's what LiveCode does: mobileVibrate 7 makes the repeat loop run 7 times. There doesn't seem to be another way.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: mobileVibrate Command

Post by Klaus » Sat Jun 08, 2013 11:32 am

Hi guys,

according to the doc, thiks is possible on iOS and Android!

The ERROR is caused from the fact that the IDE does NOT recognize MOBILE ocmmands and will throw an error when it encounters one!
I think this is completely stupid, but that's the way it is...

You will always need to use IF... THEN... with native mobile commands:

Code: Select all

on mouseUp
  beep 7

  ## ONLY execute this on the mobile simulator or real device:
  if the environment = "mobile" THEN
     mobileVibrate 7
  end if
end mouseUp
Best

Klaus

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: mobileVibrate Command

Post by Mark » Sat Jun 08, 2013 11:54 am

Hi Klaus,

On iOS, the command mobileVibrate N is possible (where N is an integer). However, when you execute this command, you will get N times a brief vibration. It is impossible to get long and short vibrations in the sense of morse code.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: mobileVibrate Command

Post by Klaus » Sat Jun 08, 2013 12:10 pm

Hi Mark,

oh, yes, sorry, my fault, need to read more carefully!


Best

Klaus

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: mobileVibrate Command

Post by Mark » Sat Jun 08, 2013 12:27 pm

That's ok, Klaus. I guess my answer wasn't complete.

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”