Creating a revBrowser in a separate stack

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
montymay
Posts: 145
Joined: Thu Jul 18, 2013 5:23 am

Creating a revBrowser in a separate stack

Post by montymay » Fri Jul 18, 2014 6:55 am

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

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Creating a revBrowser in a separate stack

Post by MaxV » Fri Jul 18, 2014 9:37 am

Did you mispell "revBrowserSt" intead of "revBrowserSet" in BrowserSetURL?
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

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

Re: Creating a revBrowser in a separate stack

Post by Klaus » Fri Jul 18, 2014 5:55 pm

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

montymay
Posts: 145
Joined: Thu Jul 18, 2013 5:23 am

Re: Creating a revBrowser in a separate stack

Post by montymay » Sat Jul 19, 2014 3:43 am

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

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

Re: Creating a revBrowser in a separate stack

Post by Klaus » Sat Jul 19, 2014 2:46 pm

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

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”