Loading local files into revBrowser (Mac)

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Loading local files into revBrowser (Mac)

Post by Simon » Wed Mar 12, 2008 3:20 am

Hello,
I'm having troubles with loading local files and Mac.
I've got the whole stackpath() thing down and it works well with Windows, displaying the html in the browserimage.
But what's the trick for getting Mac's to display local html?

TIA (Mark)

Simon

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Wed Mar 12, 2008 10:38 am

Haha :oops: maybe I should pass on your question to someone else, Simon? (assuming that you mean me)....

Anyway, it looks like something is wrong with the path to the html file, perhaps stackpath() returns an incorrect value, or there is a problem with the browser external on the Mac.

Are you running the Mac version as a standalone? Did you make sure to include the browser external?

Is the HTML file in the same location relative to the stack, on both Mac and PC?

If the answer to both questions is yes, could you post your stackpath() function here?

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Post by Simon » Wed Mar 12, 2008 9:15 pm

Hi Mark,
Yes on Mac standalone.
Yes on browser external (same one used by Mac and PC?)
Yes on relative position.

Code: Select all

function stackPath
  put the filename of this stack into tPath
  set the itemdel to "/"
  if "Mac" is in platform() then
    get offset(".app/Contents/MacOS/", tPath)
    if it > 0 then
      delete char it to len(tPath) of tPath
    end if
  end if
  delete last item of tPath
  return tPath &"/"
end stackPath
I've been able to access other files using this script for both PC and Mac, just can't load local html into revBrowser on Mac. But I can load external domains.

Thanks again,
Simon

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Wed Mar 12, 2008 10:07 pm

Hi Simon,

I am not sure what you want to achieve with your function. There is no folder with the name/path returned by your function.

I assume you have an html file next to your standalone and let's assume that your standalone is called "standalone". The standalone is actually a folder. This folder is called "standalone.app".

To get the parent folder of your standalone, all you need to do is:

Code: Select all

put the effective filename of me into myPath
set the itemDel to slash
if the platform is "MacOS" then
  return (item 1 to -5 of myPath) & slash
else return (item 1 to -2 of myPath) & slash
Does this work for you?

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Post by Simon » Wed Mar 12, 2008 11:16 pm

Hi Mark,
The part I left out of the stackPath()

Code: Select all

put (stackPath() & "intro.html") into appPath
Your code worked the same, works on PC not on Mac.
I really don't think it's a path problem as I have used my code in a bunch of apps that have no trouble finding other types of files.

I've reduced the html to just have 1 jpg in it, nothing fancy, but Mac will only show a white screen.

Regards,
Simon

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Wed Mar 12, 2008 11:39 pm

Simon,

The white screen, is that just your card?

Do you have a bundle called revBrowser.bundle in the externals folder of your standalone?

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Post by Simon » Wed Mar 12, 2008 11:57 pm

Hi Mark,
I changed the card color to green and so no, it's not the card.

Yes, under MacOS/Externals/revbrowser.bundle

Thanks for your time on this,
Simon

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Thu Mar 13, 2008 1:54 am

Hi Simon,

I'd check that your html file exists, just to be sure:

Code: Select all

if there is a file <your file> then
  revBrowserSet gBrowserID,"url","file://" & <your file>
else
  beep
  answer "No such file!" with "Okay"
end if
Here, I assume that your file path starts with a slash. If not, you'll need to add one.

It is also possible that the jpg file specified in the html code is not available. Have you checked this?

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Post by Simon » Thu Mar 13, 2008 3:39 am

Hi Mark,
hmm... no beep and no answer.
The html is ok, double clicking in finder Safari opens and it displays correctly.

Simon

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Thu Mar 13, 2008 12:07 pm

Hi Simon,

Can you turn on error reporting in the standalone settings and build a new standalone? Which version of Mac OS X are you using?

I have created a stack with the same setup, which works fine on Mac and Win.

I have put the stack here:

http://economy-x-talk.com/test.zip

This will stay available during the next few days.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Thu Mar 13, 2008 12:49 pm

Simon...

You have probably ran into a bug. I did a test on Mac OS X 10.3.9.

http://quality.runrev.com/qacenter/show_bug.cgi?id=6063

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

alex298
Posts: 101
Joined: Mon May 01, 2006 1:17 pm

Post by alex298 » Tue May 06, 2008 3:30 am

Hi Mark,
I have created a stack with the same setup, which works fine on Mac and Win.

I have put the stack here:

http://economy-x-talk.com/test.zip

This will stay available during the next few days.
I also wish to load local webpages into the revBrowser. Could you please put your test stack on your website again?

Thanks and best regards
Alex
Nice to meet all of you.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Post by Simon » Sat Nov 15, 2008 2:25 pm

OK, I found the trick (after how long???)
Because it's revBrowser running Safari, Mac needs that "File://" before the actual file name.
Should have looked closer at your code Mark.

Regards,
Simon

Post Reply