Script to launch PDF
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Script to launch PDF
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
Thanks!
Benjamin
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Contact:
Almost there, just by writing your subject
HTH,
Jan Schenkel.

Code: Select all
launch document "<the path to your PDF file>"
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
launch pdf
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
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
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Contact:
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.
HTH,
Jan Schenkel.
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
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
NOTHING!
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
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
As Jan already wrote in his first post: Use the correct syntax!
should do the trick.
Best
Klaus
Code: Select all
...
launch DOCUMENT tPath
...
Best
Klaus
Hi,
You may find that the launch command is unreliable in older versions of Revolution. You might want to try the following script:
I didn't test this script, but the approach works.
Best,
Mark
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
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
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Getting error from script
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
Type Chunk: can't set property
Object Button
Line put item 1 to -2 of the effective filename of me into myPath
Hint mouseUp
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
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
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?
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
Dear Stormy1,
You might want to add a few lines to check that your file actually exists.
Kind regards,
Mark
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
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
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode