Page 1 of 2

Script to launch PDF

Posted: Sun Nov 30, 2008 4:00 am
by pastrana
How do I launch from rev Studio a PDF doc from an specific folder in mac or pc? I can't find a solution in the previous forum threads.
Thanks!
Benjamin

Posted: Sun Nov 30, 2008 8:19 am
by Janschenkel
Almost there, just by writing your subject :-)

Code: Select all

launch document "<the path to your PDF file>"
HTH,

Jan Schenkel.

launch pdf

Posted: Mon Dec 01, 2008 3:50 am
by pastrana
I am really getting crazy.

I tried the script but nothing happens!

on mouseUp
launch "/cover.pdf"
end mouseUp

the PDf doc & stack are in the same directory and even the Preview mac application.

I am really anxious to use Revolution for a Big Project but this simple
tasks forces me to use Flash!

I have version STUDIO
2.7 build 197

Posted: Mon Dec 01, 2008 6:03 am
by TonyL
Try removing the slash:

launch "cover.pdf"

Posted: Mon Dec 01, 2008 6:40 am
by Janschenkel
First of all, the Revolution engine will not automatically include the current stack's hard disk location in its search tree. So you may have to use a full path to your PDF file - which you can derive from the 'effective filename' of your stack.
Secondly, the 'launch document' variant was introduced in Revolution 2.7.1 build 236, so I'm afraid you'll have to stick with the 'launch' command. So we end up with the following script.

Code: Select all

on mouseUp
  put the effective filename of this stack into thePath
  set the itemDelimiter to "/"
  put "cover.pdf" into the last item of thePath
  lanch thePath
end mouseUp
HTH,

Jan Schenkel.

NOTHING!

Posted: Mon Dec 01, 2008 7:36 am
by pastrana
Thansk JAN, I tried
and here is a small movie I recorder to show nothing happens with the script.

The movie executing script
http://www.sandovale.com/revolution/pdf.mov

THE STACK
http://www.sandovale.com/revolution/PDF.rev


THE PDF doc to launch
http://www.sandovale.com/revolution/battlechic


any help will be appreciated!

Benjamin

Posted: Mon Dec 01, 2008 9:18 am
by Klaus
As Jan already wrote in his first post: Use the correct syntax!

Code: Select all

...
launch DOCUMENT tPath
...
should do the trick.


Best

Klaus

Posted: Mon Dec 01, 2008 10:29 am
by Mark
Hi,

You may find that the launch command is unreliable in older versions of Revolution. You might want to try the following script:

Code: Select all

set the itemDel to slash
put item 1 to -2 of the effective filename of me into myPath
put "/battlechic.pdf" after myPath
if the platform is "MacOS" then
  put revMacFromUnixPath(myPath) into myPath
  put "tell application 'Finder' to open item '" & myPath & "'" into myScript
  replace "'" with quote in myScript
  do myScript as AppleScript
else if the platform is "Win32" then
  replace slash with backslash in myPath
  put "start '' '" & myPath & "'" into myShell
  get shell(myShell)
end if
I didn't test this script, but the approach works.

Best,

Mark

Getting error from script

Posted: Mon Dec 01, 2008 4:37 pm
by pastrana
executing at 11:34:52 AM
Type Chunk: can't set property
Object Button
Line put item 1 to -2 of the effective filename of me into myPath
Hint mouseUp

Posted: Mon Dec 01, 2008 5:18 pm
by pastrana
Hello Mark, I tried your script but then script (the bold line) gets highlited as an error.

on mouseUp
set the itemDel to slash
put item 1 to -2 of the effective filename of me into myPath
put "/battlechic.pdf" after myPath
if the platform is "MacOS" then
put revMacFromUnixPath(myPath) into myPath
put "tell application 'Finder' to open item '" & myPath & "'" into myScript
replace "'" with quote in myScript
do myScript as AppleScript
else if the platform is "Win32" then
replace slash with backslash in myPath
put "start '' '" & myPath & "'" into myShell
get shell(myShell)
end if
end mouseUp

Posted: Mon Dec 01, 2008 7:09 pm
by SparkOut
I think "me" in this context is meant to refer to the stack - when using "me" in the mouseUp handler you will be using it in the context of a button not a stack.

D oes it work if you replace that line as follows?

Code: Select all

put item 1 to -2 of the effective filename of this stack into myPath

Posted: Mon Dec 01, 2008 7:09 pm
by Mark
Hello pastrana,

"of me" should be "of this stack".

Best,

Mark

Posted: Mon Dec 01, 2008 7:32 pm
by pastrana
ALELUYA!

Thanks Mark!

Now it worked!

:D :D :D :D :D :D :D :D

Posted: Sun Jul 19, 2009 7:05 pm
by Stormy1
Hi Guys

I've tried this script in my program and it works fine while in Revolution but when I create a standalone, nothing happens?

Is this something to do with the name of the standalone?

Not sure why its happening. Any ideas?

Thanks

Posted: Sun Jul 19, 2009 8:07 pm
by Mark
Dear Stormy1,

You might want to add a few lines to check that your file actually exists.

Code: Select all

if not (there is a file myPath) then
  beep
  answer error "Can't find file" && myPath
else
  -- remainder of script
end if
Kind regards,

Mark