Subscribe Bookmark RSS Feed

Problem with pathes in SavePDF

sebastianhoffme

Community Trekker

Joined:

Mar 27, 2015

Dear JMP-Team,

I was wondering if there is anything that I am doing wrong because SavePDF does not seem to use my path-argument properly. This is the essential part of my code:

save path = "C:/Basti/Desktop";

graph1 = Graph Builder( ... ) << Report;

graph1 << Set Page Setup( margins( 1, 1.25, 0.25, 1 ), scale( 1.1 ), portrait( 0 ), paper size( "A4" ) );

graph1 << SavePDF( save path || "Graphs 1 and 2_" || Char( As Date( Today() ) ) || ".pdf" );

Instead of saving the pdf to the desktop it is stored in the same folder as my script. Furthermore the name of the pdf looks like this:

10816_jmp.PNG

Thanks for any advice,

Sebastian

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

Thanks for all of your support!

With jeff.perkinson​'s example i was able to solve it. As your example worked for me as well I wondered what was different. Now it's obvious to me that it is not a good idea to include

Char(As Date(Today()))

into the file name, as this produces:

26Jan2016:08:58:38


Which is of course problematic for a file name as it is containing ":". Using Char( Format( Today(), "YYYYMMDD" ) ) works fine.

Thanks for the tips with the formated code as well! I really appreciate this community!

Sebastian

6 REPLIES
Jeff_Perkinson

Community Manager

Joined:

Jun 23, 2011

You need a "/" to separate the save path from the filename:

save path = "C:/Basti/Desktop/";

graph1 = Graph Builder( ... ) << Report;

graph1 << Set Page Setup( margins( 1, 1.25, 0.25, 1 ), scale( 1.1 ), portrait( 0 ), paper size( "A4" ) );

graph1 <<SavePDF( save path ||"Graphs 1 and 2_"||Char(As Date(Today()))||".pdf");

-Jeff

-Jeff
sebastianhoffme

Community Trekker

Joined:

Mar 27, 2015

Hi Jeff & thanks for the reply.

Sadly the missing "/" was just a copying error on my side. The "/" is in there, but I get the results like above.

By the way: How do I get the formated code here in the forums?

Cheers,

Sebastian

pmroz

Super User

Joined:

Jun 23, 2011

How do I get the formatted code here in the forums?

  • Copy/paste the JSL code from the JSL editor to MS-Word.
  • Then, copy/paste the code from MS-Word to here.

a = "The code looks like this";

Jeff_Perkinson

Community Manager

Joined:

Jun 23, 2011

Hmmm...I'm not having any difficulty.

path = "C:/Users/Jeff Perkinson/Desktop/";

 

dt = Open( "$SAMPLE_DATA\Big Class.jmp" );

graph1 = dt << Graph Builder(

Show Control Panel( 0 ),

Variables( X( :height ), Y( :weight ), Overlay( :sex ) ),

Elements( Points( X, Y, Legend( 1 ) ), Smoother( X, Y, Legend( 2 ) ) )

) << Report;

graph1 <<SavePDF(  path ||"XYZZY"||".pdf");

I end up with "XYZZY.pdf" on my Desktop.

Perhaps you can send a note to Tech Support and see if they can help you track down what's going on.

-Jeff

-Jeff
txnelson

Super User

Joined:

Jun 22, 2012

I had a problem with the formatting when I cut and paste, and it turned out to be the browser I was using.  I now use IE to cut and paste.  Also, I copy the script code first to MS Word, which for some reason, allows for the proper indentation of the code.

Jim
Solution

Thanks for all of your support!

With jeff.perkinson​'s example i was able to solve it. As your example worked for me as well I wondered what was different. Now it's obvious to me that it is not a good idea to include

Char(As Date(Today()))

into the file name, as this produces:

26Jan2016:08:58:38


Which is of course problematic for a file name as it is containing ":". Using Char( Format( Today(), "YYYYMMDD" ) ) works fine.

Thanks for the tips with the formated code as well! I really appreciate this community!

Sebastian