URL specification change LC8.1 to LC9.x [RESOLVED]

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: Klaus, FourthWorld, heatherlaine, kevinmiller

sritcp
Posts: 424
Joined: Tue Jun 05, 2012 5:38 pm
Location: Alexandria, Virginia

URL specification change LC8.1 to LC9.x [RESOLVED]

Post by sritcp » Sun Jan 19, 2020 8:08 pm

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
Attachments
urlSpec.png
Last edited by sritcp on Mon Jan 20, 2020 11:19 pm, edited 1 time in total.

sritcp
Posts: 424
Joined: Tue Jun 05, 2012 5:38 pm
Location: Alexandria, Virginia

Re: URL specification change LC8.1 to LC9.x

Post by sritcp » Sun Jan 19, 2020 9:13 pm

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

bogs
Posts: 4214
Joined: Sat Feb 25, 2017 10:45 pm

Re: URL specification change LC8.1 to LC9.x

Post by bogs » Sun Jan 19, 2020 10:31 pm

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. -
sritcp wrote:
Sun Jan 19, 2020 8:08 pm
file:///Users/JohnDoe/myApp/A101.pdf
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 -
aPic_pdfBrowser.png
File? I don' need no steenkin "File:" ~!
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
Which worked in the above IDE as well. IDE is 9.0.1.
Image

sritcp
Posts: 424
Joined: Tue Jun 05, 2012 5:38 pm
Location: Alexandria, Virginia

Re: URL specification change LC8.1 to LC9.x

Post by sritcp » Sun Jan 19, 2020 11:03 pm

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.

bogs
Posts: 4214
Joined: Sat Feb 25, 2017 10:45 pm

Re: URL specification change LC8.1 to LC9.x

Post by bogs » Sun Jan 19, 2020 11:47 pm

Hi Sri,
sritcp wrote:
Sun Jan 19, 2020 11:03 pm
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.
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?) :D

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 -
aPic_SlasherMac.png
Slashing my way back to you, home....
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
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.
aPic_WinBrowser.png
A window to the soul...
Image

SparkOut
Posts: 2067
Joined: Sun Sep 23, 2007 4:58 pm

Re: URL specification change LC8.1 to LC9.x

Post by SparkOut » Mon Jan 20, 2020 12:07 am

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.
two slashes, without a hostname) is never correct, but is often used.
Given the lack of localhost or server hostname, the triple slash variant appears correct.

This is appropriate syntax on Windows too - as per the specification

sritcp
Posts: 424
Joined: Tue Jun 05, 2012 5:38 pm
Location: Alexandria, Virginia

Re: URL specification change LC8.1 to LC9.x

Post by sritcp » Mon Jan 20, 2020 1:56 am

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

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2423
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: URL specification change LC8.1 to LC9.x

Post by jmburnod » Mon Jan 20, 2020 11:01 am

Hi,
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
Best regards
Jean-Marc

bogs
Posts: 4214
Joined: Sat Feb 25, 2017 10:45 pm

Re: URL specification change LC8.1 to LC9.x

Post by bogs » Mon Jan 20, 2020 11:29 am

This is certainly one of those times :D

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
The above was lifted from this lesson - see the result below -
aPic_pdfBrowser2.png
Ummmm......
Note - I see Jean-Marc had inspiration while I was plotting all that out :D
Image

sritcp
Posts: 424
Joined: Tue Jun 05, 2012 5:38 pm
Location: Alexandria, Virginia

Re: URL specification change LC8.1 to LC9.x

Post by sritcp » Mon Jan 20, 2020 1:38 pm

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

Klaus
Posts: 11497
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: URL specification change LC8.1 to LC9.x

Post by Klaus » Mon Jan 20, 2020 1:55 pm

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

sritcp
Posts: 424
Joined: Tue Jun 05, 2012 5:38 pm
Location: Alexandria, Virginia

Re: URL specification change LC8.1 to LC9.x

Post by sritcp » Mon Jan 20, 2020 3:08 pm

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:

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
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

sritcp
Posts: 424
Joined: Tue Jun 05, 2012 5:38 pm
Location: Alexandria, Virginia

Re: URL specification change LC8.1 to LC9.x

Post by sritcp » Mon Jan 20, 2020 3:37 pm

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

Code: Select all

answer file "Open"
set the htmlText of widget "Browser" to it
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

Klaus
Posts: 11497
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: URL specification change LC8.1 to LC9.x

Post by Klaus » Mon Jan 20, 2020 3:39 pm

Hi Sri,

do not use:

Code: Select all

...
## put URLendcode(it) into tTemp
## Try with:
replace SPACE with "%20" in tTemp
...
These are different!

And sorry, no idea where this is in the Acrobat preferences.
Acrobat does not take over inside the browser widget
What happens if you open that PDF right in SAFARI?


Best

Klaus

sritcp
Posts: 424
Joined: Tue Jun 05, 2012 5:38 pm
Location: Alexandria, Virginia

Re: URL specification change LC8.1 to LC9.x

Post by sritcp » Mon Jan 20, 2020 3:57 pm

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

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”