revbrowser newbie

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
gwbasic
Posts: 34
Joined: Tue Mar 16, 2010 6:39 am

revbrowser newbie

Post by gwbasic » Wed Aug 18, 2010 1:17 am

I tried out the lesson at http://lessons.runrev.com/buckets/784/lessons/15963, Launching a PDF in an external viewer but I'm getting card id 1002: execution error at line n/a () near "unknown browser id". What am I missing here?

-- My card script

local sBrowserId

on openCard
browserOpen
end openCard

on browserOpen
-- We pass the windowId of the stack to revBrowser
-- so that it can determine which window to place the
-- browser object into
put the windowid of this stack into tWinID

-- Open the browser, using the windowId and initial url
put revBrowserOpen(tWinID,"") into sBrowserId

-- Set some basic properties for the browser
revBrowserSet sBrowserId, "showborder","true"
revBrowserSet sBrowserId, "rect",rect of image "browser image"
end browserOpen

on browserClose
revBrowserClose sBrowserId
end browserClose

on browserSetURL pURL
## Set the url to be displayed to the given url
revBrowserSet sBrowserId, "url", pURL --card id 1002: execution error at line n/a () near "unknown browser id"
end browserSetURL

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: revbrowser newbie

Post by Klaus » Wed Aug 18, 2010 10:49 am

Hi gwbasic,

looks like opening the browser object gives an error, so sBrwoserId is NO number lateron!
You can check this like this in your brwoseropen handler and act accordingly:

Code: Select all

...
on browserOpen
  put the windowid of this stack into tWinID

  -- Open the browser, using the windowId and initial url
  put revBrowserOpen(tWinID,"") into sBrowserId

  ## Checkl NOW! :-)
  ## sBrwoserId will be a number on success and contain an error otherwise!
  if sBrowserId is not a number then
     answer "An error occured:" && sBrowserId

    ## We leave the handler(s) in this case!
     exit to top
  end if
   ...
end browserOpen
At least this will give you (us) a hint what might go wrong here!

Best

Klaus

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: revbrowser newbie

Post by Dixie » Wed Aug 18, 2010 11:20 am

Hi Klaus...

I looked at this as well... I have got it to open a pdf, but only if the pdf is sitting next to the stack and even then not all pdf's that I put next to the stack will open... it also quits unexpectedly and gives the 'ignore', 'report' or 'reopen' dialog...

(harry doesn't feature here!) :D

be well

Dixie
Attachments
Untitled 1.rev.zip
(1.41 KiB) Downloaded 273 times

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: revbrowser newbie

Post by bn » Wed Aug 18, 2010 11:27 am

Hi gwbasic,

I tried your script and get the same error if I dont initialize the browser in the opencard handler. This can happen if you script the stack and then try it without triggering the opencard message. To trigger the opencard message you could either just close and reopen the stack. Or if the stack only has one card add a card and go to that card and come back to your browser card. Or you could simply type "opencard" without quotes into the message box and hit the return key.
Could you try this?
Mind you I noticed that on a Mac 10.6.4 the browser did not open all PDFs. No idea why. So you might want to try different PDFs. The ones that dont work just stay empty, no error message.

regards
Bernd

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: revbrowser newbie

Post by bn » Wed Aug 18, 2010 12:55 pm

Hi Dixie, Klaus and gwbasic

I found that the PDFs that I can not open in RevBrowser are the ones that have spaces in their title. I tried to put the path string into quotes -> no go.
urlencode the path string -> no go.

a search on the list turned up:
http://runtime-revolution.278305.n4.nab ... ml#a322437

the essence being to replace the space with "%20" in the file path, works for me. There might be other funny things in the filepath, who knows?

my code now looks like this:

Code: Select all

 answer file "Please choose the file you would like to display" with type "PDF document|pdf|PDF"
   if it is not empty then
      put it into tFile
      replace " " with "%20" in tFile -- added this line
      browserSetURL tFile
regards
Bernd

Post Reply