URL specification change LC8.1 to LC9.x [RESOLVED]
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
URL specification change LC8.1 to LC9.x [RESOLVED]
I have an LC8.1 stack where, to display a local pdf file, I use a browser widget. The URL of the browser widget is set to
file:///Users/JohnDoe/myApp/A101.pdf
This works in LC8.1 but crashes LC9.5
The LC9.5 dictionary says (see image below)
(for some reason, the dictionary won’t let me copy the text; I had to screen capture!)
I tried to follow these instructions; now it doesn’t crash, but nothing shows up.
I’d appreciate any help.
(I have LC-Indy; I assume browser widget is my only option for displaying pdf files)
Regards,
Sri
file:///Users/JohnDoe/myApp/A101.pdf
This works in LC8.1 but crashes LC9.5
The LC9.5 dictionary says (see image below)
(for some reason, the dictionary won’t let me copy the text; I had to screen capture!)
I tried to follow these instructions; now it doesn’t crash, but nothing shows up.
I’d appreciate any help.
(I have LC-Indy; I assume browser widget is my only option for displaying pdf files)
Regards,
Sri
Last edited by sritcp on Mon Jan 20, 2020 11:19 pm, edited 1 time in total.
Re: URL specification change LC8.1 to LC9.x
Could someone give an example of setting the browser URL?
set the URL of widget "Browser" to tLocalFile
What is an example specification of tLocalFile?
Thanks,
Sri
set the URL of widget "Browser" to tLocalFile
What is an example specification of tLocalFile?
Thanks,
Sri
Re: URL specification change LC8.1 to LC9.x
If you didn't make a typo in your first post, it would appear first of all that you have an extra "/" in the file path, i.e. -
Other than that, the url can be specified just as in every other version of Lc back to before time was invented, like this - To use the above ... erm, questionable url as an example, you might try -
Which worked in the above IDE as well. IDE is 9.0.1.
If it looks that way in code, thats a problem.
Other than that, the url can be specified just as in every other version of Lc back to before time was invented, like this - To use the above ... erm, questionable url as an example, you might try -
Code: Select all
local tLocalFile
on openStack
put "c://Users/x/myApp/all.pdf" into tLocalFile
end openStack
on mouseUp
set the URL of widget "Browser" to tLocalFile
end mouseUp
Re: URL specification change LC8.1 to LC9.x
Hi bogs:
In Mac, /Users is the root directory and /Users/JohnDoe is the "Home" directory.
So, it is file:// followed by the full path name (giving rise to "///")
And it works in LC8.1, so the syntax is correct.
Also, I am surprised that you say that simply putting the file path (without the keyword "file:) works for you.
How would the browser know if it is file:, binfile:, http:, or ftp: ?
I tried it (on LC9.5.1) and LC crashes immediately.
If it worked for you, I'd very much like an example stack.
I'm surprised that more people haven't come across this issue in their work! Unless I am missing something basic ....
Thanks,
Sri.
In Mac, /Users is the root directory and /Users/JohnDoe is the "Home" directory.
So, it is file:// followed by the full path name (giving rise to "///")
And it works in LC8.1, so the syntax is correct.
Also, I am surprised that you say that simply putting the file path (without the keyword "file:) works for you.
How would the browser know if it is file:, binfile:, http:, or ftp: ?
I tried it (on LC9.5.1) and LC crashes immediately.
If it worked for you, I'd very much like an example stack.
I'm surprised that more people haven't come across this issue in their work! Unless I am missing something basic ....
Thanks,
Sri.
Re: URL specification change LC8.1 to LC9.x
Hi Sri,
The screen shot was taken on a Win 7 box, the browser widget has some ... issues on my 'nix os, so I'm unsure as to how well that would help you out.
I did open an older OSX image to experiment with file paths there (10.6.6), opening a terminal I was able to reach my users folder without 3 slashes, as shown below - Not sure that helps you any more than the last did, but it is what it is.
As for a sample stack, really all the code you see is all there is. I put it in the card script,
The stack setup is simply a stack with a browser widget, run the 'openStack' handler, click on the stack (where ever the browser aint), and voila. Again, this is on Windows, maybe a difference there.
Well, I don't have a Mac that can run 9.x, so I am probably out for the rest of this trouble shooting heh. However, I wouldn't make any large wagers that the syntax is correct because it passed in a previous version of Lc. I would defer to someone using Mac, however, I would at least give removing the extra slash a shot if we don't hear from someone else first (Klaus? Jacque?)
The screen shot was taken on a Win 7 box, the browser widget has some ... issues on my 'nix os, so I'm unsure as to how well that would help you out.
I did open an older OSX image to experiment with file paths there (10.6.6), opening a terminal I was able to reach my users folder without 3 slashes, as shown below - Not sure that helps you any more than the last did, but it is what it is.
As for a sample stack, really all the code you see is all there is. I put it in the card script,
Code: Select all
local tLocalFile
on openStack
put "c://Users/x/myApp/all.pdf" into tLocalFile
end openStack
on mouseUp
set the URL of widget "Browser" to tLocalFile
end mouseUp
Re: URL specification change LC8.1 to LC9.x
https://en.m.wikipedia.org/wiki/File_URI_scheme
The section "How many slashes?" indicates that 3 slashes is correct in the scenario that file: is followed by two slashes as an empty hostname plus a third slash as the leading character in the path.
This is appropriate syntax on Windows too - as per the specification
The section "How many slashes?" indicates that 3 slashes is correct in the scenario that file: is followed by two slashes as an empty hostname plus a third slash as the leading character in the path.
Given the lack of localhost or server hostname, the triple slash variant appears correct.two slashes, without a hostname) is never correct, but is often used.
This is appropriate syntax on Windows too - as per the specification
Re: URL specification change LC8.1 to LC9.x
1. It appears that the Window's version is being very forgiving! The Mac version crashes every time!
2. The standard compliance text I had posted in the original post says that we must encode the URL. It is not necessary in my example (all chars are alphanumeric, no spaces). I went ahead and converted it using URLencode(), anyway. No luck.
I think this probably is a bug. I can't be sure until I know the correct syntax for setting the URL of the widget "browser"
Sri
2. The standard compliance text I had posted in the original post says that we must encode the URL. It is not necessary in my example (all chars are alphanumeric, no spaces). I went ahead and converted it using URLencode(), anyway. No luck.
I think this probably is a bug. I can't be sure until I know the correct syntax for setting the URL of the widget "browser"
Sri
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: URL specification change LC8.1 to LC9.x
Hi,
This works fine here (OS X 10.13, LC 9.5.0 or 9.6.0 dp 1 with a pdf file)
Best regards
Jean-Marc
This works fine here (OS X 10.13, LC 9.5.0 or 9.6.0 dp 1 with a pdf file)
Code: Select all
on mouseup
answer file "open"
set the url of widget 1 to it -- it = "file:///Users/MyName/Documents/testWidget.PDF"
end mouseup
Jean-Marc
https://alternatic.ch
Re: URL specification change LC8.1 to LC9.x
This is certainly one of those times
Sri, do me a favor and try this (works on 10.6.6 with the latest Lc I can run) -
Same stack setup as above, just a stack with a browser, in the card or stack script put -
The above was lifted from this lesson - see the result below -
Note - I see Jean-Marc had inspiration while I was plotting all that out
Sri, do me a favor and try this (works on 10.6.6 with the latest Lc I can run) -
Same stack setup as above, just a stack with a browser, in the card or stack script put -
Code: Select all
on mouseUp
local tFile
put "/Users/<your user name/myApp/FileName.pdf" into tFile
# alternately, this also appears to work
/*
put specialFolderPath("Home") & "/myApp/FileName.pdf" into tFile
*/
// Allow for spaces in filenames
replace " " with "%20" in tFile
set the url of widget "browser" to tFile
end mouseUp
Re: URL specification change LC8.1 to LC9.x
Hi Jean-Marc and bogs:
No luck! LC crashes every time!
(Just to be sure, I shut down and restarted my computer -- to rule out system corruption issues. Also, the fact it works in LC8.1 rules out a lot of other possibilities).
MacOS 10.14.5, LC 9.5.1
I guess it is the OS (Mojave). Maybe someone with 10.14.x could confirm.
Thanks,
Sri
No luck! LC crashes every time!
(Just to be sure, I shut down and restarted my computer -- to rule out system corruption issues. Also, the fact it works in LC8.1 rules out a lot of other possibilities).
MacOS 10.14.5, LC 9.5.1
I guess it is the OS (Mojave). Maybe someone with 10.14.x could confirm.
Thanks,
Sri
Re: URL specification change LC8.1 to LC9.x
Hi Sri,
LC 9.5.1 INDY, macOS 10.14.6
No crash with a PDF file in browser widget, I have to:
...
replace SPACE with "%20" in tURL
...
to make it work, but no crash, I see the PDF in the widget.
Do you have the Acrobat Reader installed? If yes, go to its preferences and see
if you can disable that Acrobat Reader "hooks" into the browser to display PDFs.
I remember from the mailing list there might be an issue with that one.
Best
Klaus
LC 9.5.1 INDY, macOS 10.14.6
No crash with a PDF file in browser widget, I have to:
...
replace SPACE with "%20" in tURL
...
to make it work, but no crash, I see the PDF in the widget.
Do you have the Acrobat Reader installed? If yes, go to its preferences and see
if you can disable that Acrobat Reader "hooks" into the browser to display PDFs.
I remember from the mailing list there might be an issue with that one.
Best
Klaus
Re: URL specification change LC8.1 to LC9.x
Hi Klaus:
I updated my system software to 10.14.6 (to be in sync with yours), LC9.5.1 Indy
My filepath has no spaces; nevertheless, I used URLencode, as follows:
It still crashes!
I quit my Adobe Creative Cloud app. My Acrobat Reader is not set as default for opening pdf documents (Preview is). I could not find a specific place in Acrobat Reader preferences where it "grabs" a pdf document being opened. (In any case, when I use LC8.1 on the same computer, it works; Acrobat does not take over inside the browser widget). I can't think of any other open apps interfering.
Not sure what the issue is. I am on a 2015 iMac 27".
Will keep looking,
Sri
I updated my system software to 10.14.6 (to be in sync with yours), LC9.5.1 Indy
My filepath has no spaces; nevertheless, I used URLencode, as follows:
Code: Select all
on mouseUp
local tTemp
answer file "Open"
put URLendcode(it) into tTemp
set the URL of widget "Browser" to tTemp
end mouseUp
I quit my Adobe Creative Cloud app. My Acrobat Reader is not set as default for opening pdf documents (Preview is). I could not find a specific place in Acrobat Reader preferences where it "grabs" a pdf document being opened. (In any case, when I use LC8.1 on the same computer, it works; Acrobat does not take over inside the browser widget). I can't think of any other open apps interfering.
Not sure what the issue is. I am on a 2015 iMac 27".
Will keep looking,
Sri
Re: URL specification change LC8.1 to LC9.x
Here's something else:
1. Most of the files on my Mac are in iCloud Drive (local drive that is backed up in iCloud). I had specifically created a folder *outside* of iCloud drive for keeping documents that I was using in my LiveCode app. Accessing these pdf documents is what is crashing LC.
2. I copied the pdf file into a folder that is *inside* the iCloud drive. Now, LC does not crash, BUT the document does not get displayed (just white space). The iCloud Drive is transparent, i.e., when I run
answer file "Open"
on LC, it returns /Users/myName/Documents/..... (actually, the Documents folder is inside iCloud folder).
3. I converted the pdf file to html and it works without any problem, regardless of where the file is (inside or outside iCloud drive)
At this point, I know LC doesn't crash if I access the pdf file inside the iCloud drive, but it doesn't display it in the browser widget.
It is looking like a Mac issue rather than LC issue.
Sri
1. Most of the files on my Mac are in iCloud Drive (local drive that is backed up in iCloud). I had specifically created a folder *outside* of iCloud drive for keeping documents that I was using in my LiveCode app. Accessing these pdf documents is what is crashing LC.
2. I copied the pdf file into a folder that is *inside* the iCloud drive. Now, LC does not crash, BUT the document does not get displayed (just white space). The iCloud Drive is transparent, i.e., when I run
answer file "Open"
on LC, it returns /Users/myName/Documents/..... (actually, the Documents folder is inside iCloud folder).
3. I converted the pdf file to html and
Code: Select all
answer file "Open"
set the htmlText of widget "Browser" to it
At this point, I know LC doesn't crash if I access the pdf file inside the iCloud drive, but it doesn't display it in the browser widget.
It is looking like a Mac issue rather than LC issue.
Sri
Re: URL specification change LC8.1 to LC9.x
Hi Sri,
do not use:
These are different!
And sorry, no idea where this is in the Acrobat preferences.
Best
Klaus
do not use:
Code: Select all
...
## put URLendcode(it) into tTemp
## Try with:
replace SPACE with "%20" in tTemp
...
And sorry, no idea where this is in the Acrobat preferences.
What happens if you open that PDF right in SAFARI?Acrobat does not take over inside the browser widget
Best
Klaus
Re: URL specification change LC8.1 to LC9.x
It is getting more complicated!
1. I tried to load an online pdf document (from Adobe, no less) and copied into the URL field of the widget the following:
https://www.adobe.com/support/products/ ... xplain.pdf
LC crashed!
2. I tried an online html document, a web page address; copied and pasted into the URL field.
No problem, it works!
This means that iCloud drive is not the root of the problem.
Since Klaus has the same MacOS and LC versions and it works for him, my current working hypothesis is that having Adobe Creative Cloud installed on my computer (though no app is open, including Adobe Acrobat Reader) is somehow creating the issue. (This assumes that Klaus doesn't have Adobe CC on his computer!!)
Regards,
Sri
1. I tried to load an online pdf document (from Adobe, no less) and copied into the URL field of the widget the following:
https://www.adobe.com/support/products/ ... xplain.pdf
LC crashed!
2. I tried an online html document, a web page address; copied and pasted into the URL field.
No problem, it works!
This means that iCloud drive is not the root of the problem.
Since Klaus has the same MacOS and LC versions and it works for him, my current working hypothesis is that having Adobe Creative Cloud installed on my computer (though no app is open, including Adobe Acrobat Reader) is somehow creating the issue. (This assumes that Klaus doesn't have Adobe CC on his computer!!)
Regards,
Sri