Page 1 of 1

Creating a revBrowser in a separate stack

Posted: Fri Jul 18, 2014 6:55 am
by montymay
The LiveCode tutorial shows how to open a PDF in the LC browser by using a button and selecting a PDF file in the OS directory, but I want the a PDF file to open automatically in an LC browser when the user clicks on a control. I am trying to use a revBrowser in its own stack.

Here is the script of the initiating button:

Code: Select all

global tFile, sBrowserID
on mouseUp
   put the short name of this cd into tFile
   replace space with "%20" in tFile -- I read you have to do this when the name has space. True?
   put "file://"&tFile&".pdf" into tFile -- I read somewhere that "file://" must be prepended to the filename
   go stack "pdf viewer" -- would it be simple to put the browser on a separate cd of the same stack?
end mouseup
Here is the cd script of the browser:

Code: Select all

global sBrowserID, tFile

on openCard
   browserOpen
end openCard

on browserOpen
   put the windowID of this stack into tWinID
   put revBrowserOpen(tWinID,"") into sBrowserID
   revBrowserSet sBrowserID, "showborder","true"
   revBrowserSet sBrowserID, "rect", rect of image "browser image"
end browserOpen
--- the browser does open

BrowserSetURL tFile

on BrowserSetURL
   revBrowserSt sBrowserID, "url", tFile
end BrowserSetURL

on mouseup
   global tFile
   revBrowserClose sBrowserID
   delete global tFile
   close this stack
end mouseup
But the file will not display in the browser. The global variable tFile reads, e.g., file:://01-0101%20Title.pdf. Can't find any discussion on this forum. I'm hoping my error is simple and easy to see. Thank you for your help.

Monty May

Re: Creating a revBrowser in a separate stack

Posted: Fri Jul 18, 2014 9:37 am
by MaxV
Did you mispell "revBrowserSt" intead of "revBrowserSet" in BrowserSetURL?

Re: Creating a revBrowser in a separate stack

Posted: Fri Jul 18, 2014 5:55 pm
by Klaus
Hi Monty,

question is, where exactly are the PDF files?
...in the OS directory
? And that is where?

Obviously this:

Code: Select all

global tFile, sBrowserID
on mouseUp
   put the short name of this cd into tFile
   replace space with "%20" in tFile -- I read you have to do this when the name has space. True?
   put "file://"&tFile&".pdf" into tFile -- I read somewhere that "file://" must be prepended to the filename
   go stack "pdf viewer" -- would it be simple to put the browser on a separate cd of the same stack?
end mouseup
does create a filename, which may be valid, but the file is simply not where you exspect it 8)


Best

Klaus

Re: Creating a revBrowser in a separate stack

Posted: Sat Jul 19, 2014 3:43 am
by montymay
To Klaus,

Thank you for your reply. Yes, my button script failed to put the full file path, so I amended it to read:

Code: Select all

put "file://c:/users/monty/documents/book/ops/"&tFile&".pdf" into tFile
I tried the script both with and without replacement of spaces in the file name with %20. The browser object displays but not the file.

If you see another obvious error, you guidance would be much appreciated.

Regards

Monty

Re: Creating a revBrowser in a separate stack

Posted: Sat Jul 19, 2014 2:46 pm
by Klaus
Hi Monty,

not sure, but do this to assure the correct URL:
Start your internet browser and OPEN a PDF file, then check the URL in the address field.

I get this in my browser: file:///Users/klaus/Desktop/s_Linie_66.pdf
So there might be another / missing in the URL!


Best

Klaus