Getting into LiveCode for iOS? Ask your questions here.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
itay1023
- Posts: 68
- Joined: Fri Sep 28, 2012 1:44 pm
Post
by itay1023 » Sun Mar 16, 2014 3:32 pm
Hi all
Does somebody know how can I code a line which identifies if the code isn't currently available?
For example: if I wrote a code that says: launch URL "skype://" , if the command isn't available because there is no Skype application installed on the iPhone, so another command will be sent.
Best,
Itay

-
dave.kilroy
- VIP Livecode Opensource Backer

- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
-
Contact:
Post
by dave.kilroy » Sun Mar 16, 2014 3:42 pm
Hi - sounds like a 'try' statement is what you are looking for:
Code: Select all
try
--your code that tries to launch Skype
catch someError
--your alternative code that you call only if Skype isn't available
end try
Although it would be more elegant to have some way of checking for an iPhone's installed apps and whether the user is currently logged in to Skype - but I have no idea how to do that whilst your app is sandboxed)
"...this is not the code you are looking for..."
-
Klaus
- Posts: 14177
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Sun Mar 16, 2014 9:58 pm
Hi itay,
what the dictionary says about "launch url":
...
When launch url is called, LiveCode checks to see if an application is available to handle the URL.
If no such application exists, the command returns "no association" in the result.
...
Like this:
Code: Select all
...
launch URL "skype://..."
if the result <> empty then
answer "Problem:" && the result
## Optional:
exit to top
end if
...
Best
Klaus
-
dave.kilroy
- VIP Livecode Opensource Backer

- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
-
Contact:
Post
by dave.kilroy » Sun Mar 16, 2014 10:12 pm
Klaus - nice, I forgot launch URL does that...
"...this is not the code you are looking for..."
-
Klaus
- Posts: 14177
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Mon Mar 17, 2014 12:57 am
THE RESULT is always worth a look!

-
dave.kilroy
- VIP Livecode Opensource Backer

- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
-
Contact:
Post
by dave.kilroy » Mon Mar 17, 2014 1:19 am
Hi Klaus - yeah you are right however I find I can't always be sure what value the result will have (cf 'it') and I often need to confirm what it SHOULD be (below is an extract from the dictionary):
Many commands (such as go and find) set the value of the result function when they finish. In most cases, if the result is empty, the command was successful; if the result is not empty, the command failed and the result contains an error message. See the specific command for information about whether it sets the result function.
Do you have a simple rule-of-thumb I can use to remind myself what the result is expected to be in common situations?
"...this is not the code you are looking for..."
-
Klaus
- Posts: 14177
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Mon Mar 17, 2014 8:49 am
Hi Dave,
sorry, no simple rule-of-thumb.
Best
Klaus