Hi Everyone
I'm having some path issues with this program which is nearly finished!
Its cross-platform and all I'm trying to do is launch an html file from a little intro stack which plays off a cd.
The html file launches fine on the Mac but I can't get Windows to go for it. Here's my script:
on mouseUp
if the platform is "MacOS" then
set the itemDel to slash
put "file://" into myCD
put item 1 to -5 of the effective filename of this stack into myPath
put "/PDFs/etc etc/index.html" after myPath
revGoURL myCD && myPath
else if the platform is "Win32" then
set the itemDel to slash
put item 1 to -5 of the effective filename of this stack into myPath
put "/PDFs/etc etc/index.html" after myPath
revGoURL & myPath
if not (there is a file myPath) then
beep
answer error "Can't find file" && myPath
else
end if
end if
end mouseUp
I tried putting file:// infront but that does nothing. Windows tries to put 'http:' in the browser on previous efforts whereas to view it manually, the browser has the drive letter. But obviously, each PC might have a different cd drive letter?
How can I get Windows to put the right prefix for the browser?
Thanks in advance
Windows Path issues
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Hi Stormy1,
I believe that file URL's should start with file:///Macintosh HD/folder/file on Mac and with file:///C:/folder/file.
Explorer indeed adds http:// in front of the URL. This only happens with file URL's and not with URL's that assume the http protocol.
I'm pretty sure this is a Rev bug.
Best,
Mark
I believe that file URL's should start with file:///Macintosh HD/folder/file on Mac and with file:///C:/folder/file.
Explorer indeed adds http:// in front of the URL. This only happens with file URL's and not with URL's that assume the http protocol.
I'm pretty sure this is a Rev bug.
Best,
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
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Hi Mark
Thanks for your response.
I have actually managed to get a script which works on Windows now after some trial and error:
on mouseUp
if the platform is "MacOS" then
set the itemDel to slash
put "file://" into myCD
put item 1 to -5 of the effective filename of this stack into myPath
put "/PDFs/etc etc /index.html" after myPath
revGoURL myCD & myPath
else if the platform is "Win32" then
set the itemDel to backslash
put "D:\" into myCD
put item 1 to -5 of the effective filename of this stack into myPath
put "\PDFs\etc etc\index.html" after myPath
launch document myCD & myPath
end if
end mouseUp
This now opens the file in the browser however, my only worry is whether the cdrom drive letter is different from the standard D: on the users machine. Is there anyway of checking what drive letter they have and incorporating it into the myCD variable?
Thanks as always
Thanks for your response.
I have actually managed to get a script which works on Windows now after some trial and error:
on mouseUp
if the platform is "MacOS" then
set the itemDel to slash
put "file://" into myCD
put item 1 to -5 of the effective filename of this stack into myPath
put "/PDFs/etc etc /index.html" after myPath
revGoURL myCD & myPath
else if the platform is "Win32" then
set the itemDel to backslash
put "D:\" into myCD
put item 1 to -5 of the effective filename of this stack into myPath
put "\PDFs\etc etc\index.html" after myPath
launch document myCD & myPath
end if
end mouseUp
This now opens the file in the browser however, my only worry is whether the cdrom drive letter is different from the standard D: on the users machine. Is there anyway of checking what drive letter they have and incorporating it into the myCD variable?
Thanks as always
Dear Stormy1,
When you create your CD, make sure that it has a label. This allows you to use the following function to retrieve label information:
Call the volumeLabels function and use an array or the lineOffset function to find the drive. Here's an example using an array:
On the Mac, you should be able to refer to a file path directly, using the label of the CD (/Volumes/MyCD/Folder/File.ext)
Best regards,
Mark
When you create your CD, make sure that it has a label. This allows you to use the following function to retrieve label information:
Code: Select all
function volumeLabels
put the volumes into myVols
repeat for each line myDrive in myVols
put volLabel(myDrive) into myLabel
if myLabel is empty then put char 1 of myDrive into myLabel
put myLabel & tab & char 1 of myDrive & cr after myList
end repeat
return char 1 to -2 of myList
end volumeLabels
function volLabel theDrive
put shell("vol" && theDrive) into myInfo
if number of lines of myInfo is 2 then
return last word of line 1 of myInfo
else return empty
end volLabel
Code: Select all
put volumeLabels() into myLabels
split myLabels by cr & tab
put myLabels["MyCD"] into myDrive
-- do anything you like with myDrive here
Best 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
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode