Choose Language Hide Translation Bar

Path Variables to deal with my disorganized files.


So here's the deal, I do a lot of presenting on lots of JMP topics for general and specific audiences. Not only different audiences but also I use a Mac and a PC virtual machine on the same laptop.  

My big problem is with links to files in JMP Journals. If the journal is for PC then my path might look like "y:\Byron\Example\.." but if its in Mac then it would look more like "/Users/Byron/Examples/.."  This means that I either code each file link to be operating system specific, or I build two versions of the journal for PC and Mac. 



I've been writing JSL for years and this didn't click until a lunch conversation with Joseph Morgan and Jeff Polzin. (actually, it was their conversation, I was just listening, on a good day the JMP heavies just a little out of my league.) 

In JSL we can set a Path Variable. I've been using "$Sample_Data\Big"  forever and the  "$Sample_Data" part of that is a path variable that directs JMP to get the file from the sample data directory.  Setting a path variable is really simple, just supply the name and the path like this:

Set Path Variable( "Examples", "Y:\Byron Wingerd\Examples" )

So now I can use the file name "$Examples\" or something like this:


to get at this file.  


This is super convenient when I move a general journal into a customer specific folder. Since the journal and customer specific data files are in the same directory I don't have to use a path to get those, and if I use "$Examples\..." to link to the general files the link works.   But this is only a small solution. The bigger problem is switching between PC and Mac.  


To deal with different operating systems I use JSL to define the Examples path depending on the operating system like this:  (This is the really great part!)

If( Host is( Mac ), Set Path Variable( "Examples", "/Users/bywing/Byron Wingerd/Examples" ));
If( Host is( Windows ), Set Path Variable( "Examples", "Y:\Byron Wingerd\Examples" ));

If I run the little bit of JSL at the beginning of my JMP session (or from a button in my journal), then  "$Example" will be evaluated correctly in the host operating system.   This means the file link "$Examples\" opens "" regardless of which operating system the Journal is opened in. 


The quick and simple for existing scripts is to add this JSL in a script button to get things sorted out.

Names Default To Here( 1 );
If( Host is( Mac ), Set Path Variable( "Examples", "/Users/bywing/Byron Wingerd/Examples" ));
If( Host is( Windows ), Set Path Variable( "Examples", "Y:\Byron Wingerd\Examples" ));
pvex = Get Path Variable( "Examples" );
	vlist(pvextb1 = Text Box( "Path variable $Examples set to:" ),
	      pvextb2 = Text Box( pvex ),
	      Button( "OK" ))

This gives me a quick text box message to let me know the path is set. 


I'm sure there are at least a dozen ways to deal with this problem/ This approach is easy to use on existing journals with links that get shared between different people. If you have similar or better methods, please post them, I'm curious to see how other people are solving this problem.

Article Labels
Article Tags