External file path name - Windows

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
GregWills
Posts: 69
Joined: Sun Aug 30, 2015 7:51 am

External file path name - Windows

Post 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
Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: External file path name - Windows

Post 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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
GregWills
Posts: 69
Joined: Sun Aug 30, 2015 7:51 am

Re: External file path name - Windows

Post 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
Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: External file path name - Windows

Post by Simon »

Hi Greg,
Is the path known by you?

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
GregWills
Posts: 69
Joined: Sun Aug 30, 2015 7:51 am

Re: External file path name - Windows

Post 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
Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: External file path name - Windows

Post 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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7423
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: External file path name - Windows

Post 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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
GregWills
Posts: 69
Joined: Sun Aug 30, 2015 7:51 am

Re: External file path name - Windows

Post 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
jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7423
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: External file path name - Windows

Post 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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
Post Reply