Page 1 of 1

External file path name - Windows

Posted: Mon Feb 29, 2016 6:38 am
by GregWills
Hi Everyone

Probably a simple question, but I have been looking for a few days for a solution. I think I have tried every combination of variations to get this to work, but no success yet!

I want to launch an external .html file (on a memory stick) from a stack (on the same memory stick). The following works fine on a Mac, but I can't get the correct syntax for Windows users.

get the platform
if the platform is "MacOS" then
launch url "file:Care/welcome.html" -- this one works on Mac :-)
end if
if the platform is "Win32" then
launch url "file\Care/welcome.html"
end if

These are a few others I have tried in desperation!!
launch url "file:Care/welcome.html"
launch url "file:/Care/welcome.html"
launch url "file\\Care/welcome.html"
launch url "file/Care/welcome.html"
launch url "file//Care/welcome.html"

Any assistance will be gratefully received.

Cheers

Greg

Re: External file path name - Windows

Posted: Mon Feb 29, 2016 6:59 am
by Simon
Hi Greg,
The easy way is to;

Code: Select all

on mouseUp
answer file "pick a file"
answer it
end mouseUp

Code: Select all

put it
is kind'a better as you can copy and paste it.

Simon

Re: External file path name - Windows

Posted: Tue Mar 01, 2016 12:05 am
by GregWills
Thanks for the suggestion Simon

I've played with that approach, but I want the web page to launch with the one click, as the person using the program won't know that they are looking for the welcome.html file.

cheers

Greg

Re: External file path name - Windows

Posted: Tue Mar 01, 2016 12:48 am
by Simon
Hi Greg,
Is the path known by you?

Simon

Re: External file path name - Windows

Posted: Tue Mar 01, 2016 2:09 am
by GregWills
Hi Simon

Yes. It is in a folder 'Care'. The Livecode stack will be in same level as the 'Care' folder.

The Mac format to refer to and open the 'welcome.html' file works fine. It's just that the syntax for Windows users is eluding me :-)

cheers

Re: External file path name - Windows

Posted: Tue Mar 01, 2016 2:39 am
by Simon
Well it should be

Code: Select all

  put the filename of this stack into tPath
  set the itemdel to "/"
  delete last item of tPath
  put "/" after tPath
  launch document tPath & "welcome.html"
Oh I see... you don't need the "file:

Simon

Re: External file path name - Windows

Posted: Tue Mar 01, 2016 5:59 pm
by jacque
You could also use specialFolderPath("resources") which will get the correct path to the resource folder on any OS. Your setup is already correct, with the Care folder at the same level as the stack.

Code: Select all

put specialFolderPath("resources") & "/Care/welcome.txt" into tPath
This will work on any desktop or mobile OS.

Re: External file path name - Windows

Posted: Wed Mar 02, 2016 12:46 am
by GregWills
Thanks Simon.
I used your script to see what was going on under the hood. The path was ok, just the url syntax wasn't launching the web browser (as I was expecting, because it was fine on a Mac). However the 'launch document' syntax did the trick. Brilliant.

Hi Jacque, thanks for your script. Seeing your name again reminds me of Revolution days :-) Hope all is well over your way.

cheers

Greg

Re: External file path name - Windows

Posted: Wed Mar 02, 2016 8:18 am
by jacque
GregWills wrote:Hi Jacque, thanks for your script. Seeing your name again reminds me of Revolution days :-) Hope all is well over your way.
Greetings back. :) Some things never change, everybody is stuck with me for better or worse.