Script to launch PDF

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

Stormy1
Posts: 31
Joined: Tue Jul 14, 2009 1:47 pm

Post by Stormy1 » Sun Jul 19, 2009 8:30 pm

Hi Mark

Thanks for that but I'm not sure where to put that in the code?

Also, I don't understand why the script works perfectly while using Revolution but not when I create a standalone?

What breaks?

Thanks

!Jerry!
Posts: 16
Joined: Tue Apr 07, 2009 3:49 pm

Post by !Jerry! » Mon Jul 20, 2009 10:45 am

Hi Stormy1,

I think you can put (and run) the code in Message Box (in Multiple Lines mode) e.g.

Jerry

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

Post by Mark » Mon Jul 20, 2009 11:10 am

Dear Stormy1,

You start your script with "on mouseUp". Put the if-then statement, which I posted, right after the line that defines the myPath variable. Put everything else, except "end mouseUp", on the line saying "-- remainder of script". Finish the script with "end mouseUp". Let me know and post your script if it doesn't work.

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

Stormy1
Posts: 31
Joined: Tue Jul 14, 2009 1:47 pm

Post by Stormy1 » Mon Jul 20, 2009 11:32 am

Thanks for that Mark

However, before I do that, I'm still not clear as to why this script (the main one you posted before) stops working after I create the standalone.

When previewing in Revolution on the Mac, the button works fine and opens the document. However, as soon as its a standalone, nothing.

According to the documentation, Revolution defaults to creating the defaultfolder to the one where the .exe is housed. That means, your script should work. But when I try it on the Mac, the button does nothing and on Windows, I get a MS-DOS black window and an error message saying it can't find file "".

I can't believe this is SO difficult to do considering its something so basic.

Thanks

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

Post by Mark » Mon Jul 20, 2009 11:47 am

Dear Stormy1,

Make the change to your script and let me know what happens.

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

Stormy1
Posts: 31
Joined: Tue Jul 14, 2009 1:47 pm

Post by Stormy1 » Mon Jul 20, 2009 1:09 pm

Hi Mark

Put the script in a few places although I'm not sure i'm getting it right.

While in Revolution, the document opens plus a system file search window which isn't obviously the right way!

However, in all cases, when spitting out a standalone, the button still does nothing.

I just still don't understand why it works in Revolution and then NOT as a standalone!!! Why have a 'launch document' command and it not do anything????

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

Post by Mark » Mon Jul 20, 2009 1:11 pm

"post your script if it doesn't work. "
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

Stormy1
Posts: 31
Joined: Tue Jul 14, 2009 1:47 pm

Post by Stormy1 » Mon Jul 20, 2009 3:30 pm

OK Mark, now we're getting somewhere!
Thanks for your patience on this.

I got your script in the right place and when running the standalone, I get the 'Can't Find File' window with the location its trying to search for.

For some reason, its adding "/Contents/MacOS" before the info I added in the script for the document location. Thats why it can't find it.

In other words, it gives the string to the .app file of the standalone which is correct but then puts "/Contents/MacOS" between that and the rest of the location of the file.

Why has that been inserted and how can I take it out?

Thanks

Stormy1
Posts: 31
Joined: Tue Jul 14, 2009 1:47 pm

Post by Stormy1 » Tue Jul 21, 2009 10:10 am

Ok, so officially, this is getting ridiculous.

For some reason, thanks to the GLX framework, I can get the file to link on the Mac using your script. However, the PC (which has never worked either) still isn't working.

I have tried loads of different permutations but have got nothing.

This is the Windows part of the script:
else if the platform is "Win32" then
replace slash with backslash in myPath
put "start '' '" & myPath & "'" into myShell
get shell(myShell)
end if

All this gives me in Windows is an empty black DOS window and a warning message saying is can find "". I have tried putting in the link etc into various places but again, nothing.

All I want to do is open a Word doc. Is that too much to ask?????

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

Post by Mark » Tue Jul 21, 2009 12:25 pm

Dear Stormy1,

Please, have a look at the folder structure of a Mac standalone. You will see that it isn't just one document but a bundle with several files and folders in it. The executable file is burried pretty deep in a nested folder. As a result, the effeective filename of a standalone or a stack saved with that standalone differs. On Mac, you get

Macintosh HD/Folder/Application.app/Contents/MacOS/Executable

while on Windows you get

C:/Folder/Executable.exe

You can do two things now. Either change your script to delete item -4 to -1 of myPath (itemDelimiter set to slash) whenever your script runs in a standalone or store the referenced file inside Macintosh HD/Folder/Application.app/Contents/MacOS/

This problem is not a bug, it is the consequence of the difference in file structure between Mac and other operating systems.

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

Post Reply