Strange cross platform behavior in 2.9

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
astroboy
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 30
Joined: Wed Apr 09, 2008 8:05 pm

Strange cross platform behavior in 2.9

Post by astroboy » Sun Jul 20, 2008 4:44 pm

Hello

I'm trying to create an application that runs on Linux and Mac OSX. The idea is to distribute it in a CD containing a small standalone for each OS, from which it can invoke the external rev stacks as needed. But I found the following strange problems:

1. Some of my stacks saved in Revolution Media 2.9 for OS X have lines like "go to card x of stack warever". They work fine in OSX, but when carried to Linux (opened in Revolution Studio 2.9 for Linux) they don't open via "go to card...", they can only be opened directly in Revolution via "File -> Open..." The workaround I found for this behavior was File -> Open the stack, then File -> Save as... to create a new file, deleting the old one and renaming the new one to the original name. That way, the stacks can be opened via "go to card...". By the way, I have the same problem if the stacks are saved in Linux, the do not open via " go to card..." in Mac OSX unless I re-save them in Rev Media for OSX!

2. If I build a standalone for OS X Intel on my Revolution 2.9 Linux (the only way I can, no enough money to buy a Revolution 2.9 for OS X) , the sound and video players don't work once the standalone app is running on OS X. The sound and video players work just fine when the stacks are opened in Revolution Media 2.9 for OSX, and even in the old Revolution Player... but not as a standalone app for Mac...

Are these bugs or am I missing something? Thanks in advance...

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

Post by Mark » Sun Jul 20, 2008 6:00 pm

Hi Astroboy,

You are using absolute paths where you should have been using relative paths. Another option is to write your scripts in such a way that they always determine the correct path to your stacks and other files before opening/using them.

By opening and saving a stack, you load the stack into memory. That's why Rev can find it. The saving itself has no effect.

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

astroboy
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 30
Joined: Wed Apr 09, 2008 8:05 pm

Post by astroboy » Sun Jul 20, 2008 11:06 pm

Hi Mark

Nope. I', using relative paths

on openStack is this:
----
global Path

if Path is empty then
put the filename of this stack into Path
repeat while last char of Path is not "/"
clear last char of Path
end repeat
end if
---
and in the button responsible for opening the stack is this script:

---
global Path

go to card 3 of stack Path&"maderism/maderism"

----

As I said in previous post, after I re-saved the stack -as a workaround- the problem went away, even after shutting down and turning on the computer, so it might not have to be something with the loading into memory...

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

Post by Mark » Sun Jul 20, 2008 11:29 pm

Hi Astroboy,

Are you sure there isn't one slash missing at the end of the global variable Path?

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

astroboy
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 30
Joined: Wed Apr 09, 2008 8:05 pm

Post by astroboy » Mon Jul 21, 2008 2:53 am

Oh, I'm pretty sure the code shown in my previous post to obtain global variable "Path" does not lack an slash at its end. I have used that little piece of code since the beginning of MetaCard times, and it is very reliable :o

You can test it :P

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

Post by Mark » Mon Jul 21, 2008 1:17 pm

Astroboy,

Maybe you should add a check to your code: if there is a file Path then ... else answer "An error occurred..." and then check both the Path variable and the actual location of the file.

I am sure that you are making a mistake somewhere. Currently, I'm making standalones with lots of files without encountering any problems*.

Best,

Mark

*) at least not the kind of problems you describe ;-)
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

astroboy
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 30
Joined: Wed Apr 09, 2008 8:05 pm

Post by astroboy » Mon Jul 21, 2008 8:11 pm

Thanks, Mark

I tried to reproduce this behavior by creating a simple mainstack (test1) with just one button, which contains the following code:

----------
on mouseUp
global Path

if Path is empty then
put the filename of this stack into Path
repeat while last char of Path is not "/"
clear last char of Path
end repeat
end if

go to card 1 of stack Path&"test2.rev"
end mouseUp
-------

And, of course, also created a main stack named "test2.rev"...

And they work just fine in both OSes!!!... grrrr... it seems that a relatively simple app causes no trouble, but those stacks (which are about 20 MB in size) are not good in opening betwen OSes, who knows, maybe they carry some stuff (they were created in MetaCard a long time ago, and even I re-save them to the recent Rev format, but, I don't know..)

Changing the subject, I created a standalone for OS X in Linux, and when it is opened in OS X, no sound or video came out of the players. I thought it had something to do with creating it in Linux, but not so.

I took the liberty of use a 30 days demo of Studio for Mac OS X to create the standalone in its own native environment. Guess what? No sound nor video in the standalone, either!!! (but they work just fine when running the stacks in Revolution Studio and Revolution Player)... I'm not using anything strange, just simple "start player" functions...

Thanks in advance for your help...

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

Post by Mark » Mon Jul 21, 2008 8:23 pm

Dear mister Astroboy,

Are you sure that the video files are available? How did you check this?

Best regards,

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

astroboy
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 30
Joined: Wed Apr 09, 2008 8:05 pm

Post by astroboy » Tue Jul 22, 2008 2:08 am

"Mister Astroboy?" ha ha ha

well, this is the code on a button that start a player (and yes, the mp4 file is there):

-------
on mouseUp
global Path

show graphic "cuadro" with visual effect stretch from center fast
set the loc of player "video" to 340,219
set the filename of player video to Path&"diaz2.mp4"
start player video

end mouseUp
-----------


The global variable Path is set with the code shown in a previous post on this thread.

The standalone app has been running the video and sound players for years in Linux, and two months ago I did a standalone for Windows, just for fun. No problem either. But I can't figure out why a OS X standalone does not play videos or sound, while the stacks opened in Revolution Media, Revolution Studio and Revolution Player for OS X play all sound and video without any problem...

astroboy
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 30
Joined: Wed Apr 09, 2008 8:05 pm

Post by astroboy » Tue Jul 22, 2008 2:42 am

I finally figured out why the sounds and videos didn't work on standalone, but they do work in Revolution, Media and Player for OS X and Linux.

When running as a OSX standalone, the global variable Path changes because the apps in Mac are a disguised directory. So in Linux (standalone and Studio) and in mac OS X (Media, Studio and Player) an instruction that reads set the filename of player video to Path&"diaz.mp4" get translated as "/Users/astroboy/history/diaz.mp4", where as the same instruction on a standalone is translated as "/Users/astroboy/history/history.app/Contents/MacOS/diaz.mp4" thus sort of messing everything if I do not change the location of those files...

The only missing thing is why do I have to re-save in Linux the stacks created in OS X to be able to open them via "go to card x of stack y". If I figure it I let all know...

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Post by mwieder » Tue Jul 22, 2008 7:53 pm

Mister Astroboy (hey - it's traditional now) -

You may need to mess with the defaultPath setting to get those. Or, as you pointed out, move the media files around and not mess with the code. I find mac app bundles a pain to wrap my head around - have to reinvent it each time I get there. Then it makes sense, and then I forget it all the next day.

astroboy
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 30
Joined: Wed Apr 09, 2008 8:05 pm

Post by astroboy » Tue Jul 22, 2008 10:28 pm

Well, since the goal is to have an app that runs on Linux on Mac using the same stacks, videos and sounds, wouldn't make much sense to move those files inside the mac .app (Linux users certainly would not appreciate that!) :lol:

So I added this code for the stack to be the standalone, to have the global Path set where it should look stacks and video/sound files:

-----
if Path is empty then
put the filename of this stack into Path
repeat while last char of Path is not "/"
clear last char of Path
end repeat
end if

if the platform is "MacOS" and item 1 of the systemVersion >= 10 then
--clear MacOS
clear last char of Path
repeat while last char of Path is not "/"
clear last char of Path
end repeat

--clear Contents
clear last char of Path
repeat while last char of Path is not "/"
clear last char of Path
end repeat

--clear history.app
clear last char of Path
repeat while last char of Path is not "/"
clear last char of Path
end repeat
end if
------

This is my first standalone on OS X, so I just hope this app directory structure does not change on each version or release...

Best Regards from "Mr. Astroboy"

Post Reply

Return to “Mac OS”