Launch URL with tilde (~) [SOLVED]

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

Zax
Posts: 519
Joined: Mon May 28, 2007 10:12 am
Contact:

Re: Launch URL with tilde (~) ?

Post by Zax » Thu Jul 07, 2016 4:51 pm

[-hh] wrote:[Please tell us the versions you use: MacOS, Firefox, and LiveCode.]

Code: Select all

tell application "Safari" -- or "Firefox" or "Google Chrome"
   open location "http://ssl15.ovh.net/%7EmyDomain/myPage.html"
   -- open location "http://ssl15.ovh.net/~myDomain/myPage.html" -- works also
end tell
You could try it from the Applescript Editor to see if your LC version is the culprit. If not then you could try the different browsers if there are differences.

The Applescript solution works fine with

Code: Select all

open location "http://ssl15.ovh.net/~myDomain/myPage.html"
but it's not applicable with Windows.

I use:
  • LC 7.0 Community Edition
  • OS X 10.6.8
  • Firefox 45 (default browser)
  • Safari 5.1.10 (latest version for OS X 10.6)
My old Safari doesn't want "%7e" in URL, it converts it to "E8B3".

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Launch URL with tilde (~) ?

Post by [-hh] » Thu Jul 07, 2016 6:48 pm

1. Please try to use the *latest* stable LC 7, there were some Unicode issues with the first versions. May be this solves all problems.
2. In order to launch the URI with the *user's default browser* you may also try
(uses current system's launch services):

Code: Select all

-- launches myURL with user's default browser, works with LC 6/7/8
put "https://ssl15.ovh.net/~myDomain/myPage.html" into myURL
switch the platform
  case "MacOS"
    put shell ("open " & myURL) into nirvana
    break
  case "Win32"
    put shell ("explorer " & myURL) into nirvana
    break
  default
    launch URL myURL
    break
end switch
shiftLock happens

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: Launch URL with tilde (~) ?

Post by MaxV » Fri Jul 08, 2016 8:41 am

Zax wrote:
MaxV wrote:What happen with this code

Code: Select all

put quote & "https://ssl15.ovh.net/~myDomain/myPage.html" & quote into myURL
put shell("/Applications/Firefox.app/Contents/MacOS/firefox " & myUrl)
??
If Firefox is already launched, Message Box contains:
...
If not, it works but it freezes LC.
OK, here the solution:

Code: Select all

put quote & "https://ssl15.ovh.net/~myDomain/myPage.html" & quote into myURL
put shell("/Applications/Firefox.app/Contents/MacOS/firefox " & myUrl & " &")
the space and & char after all permit to continue. It's a firefox on Mac behavviour.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Zax
Posts: 519
Joined: Mon May 28, 2007 10:12 am
Contact:

Re: Launch URL with tilde (~) ?

Post by Zax » Fri Jul 08, 2016 1:54 pm

[-hh] wrote:1. Please try to use the *latest* stable LC 7, there were some Unicode issues with the first versions. May be this solves all problems.
2. In order to launch the URI with the *user's default browser* you may also try
(uses current system's launch services):

Code: Select all

-- launches myURL with user's default browser, works with LC 6/7/8
put "https://ssl15.ovh.net/~myDomain/myPage.html" into myURL
switch the platform
  case "MacOS"
    put shell ("open " & myURL) into nirvana
    break
  case "Win32"
    put shell ("explorer " & myURL) into nirvana
    break
  default
    launch URL myURL
    break
end switch
This code works! Thank you very much :)
BTW, I tried with the regular "launch URL" command with LC 7.14 but the problem is the same.

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Launch URL with tilde (~) ?

Post by [-hh] » Fri Jul 08, 2016 2:21 pm

Aha, your post revealed a text encoding problem of LC's "launch URL" with MacOS 10.6.
You could think about reporting this as bug. Also MaxV's solution (without his workaround) shouldn't freeze LC.

Let me denote for completeness another candidate for launching an URL with the default webbrowser in case "launch URL ..." doesn't work.
This works here with several linux flavours and also on MacOS and also on Win 7/10 (if Python is installed):

Code: Select all

put shell("python -m webbrowser " & myURL) into nirvana
Last edited by [-hh] on Fri Jul 08, 2016 2:58 pm, edited 1 time in total.
shiftLock happens

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: Launch URL with tilde (~) ?

Post by MaxV » Fri Jul 08, 2016 2:57 pm

[-hh] wrote: ... Also MaxV's solution (without his workaround) shouldn't freeze LC. ...
No without the " &" it must freeze livecode. The Firefox guideline on Mac requires to use " &", otherwise the shell freezes untill Firefox closes.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Post Reply