Re: isMacintosh boolean in a macro?

Posted by Wayne Rasband on
URL: http://imagej.273.s1.nabble.com/isMacintosh-boolean-in-a-macro-tp3694802p3694803.html

On Oct 11, 2008, at 7:01 AM, Bill Mohler wrote:

> I've just come across the mismatch in path punctuation in macros  
> between Mac and Windows:  "/" vs "\\" to demarcate directory levels  
> when I record a save command in the recorder.
>
> I found an isMacintosh boolean in some of the ij. code.  But I  
> didn't find an obvious command in the macro language command list  
> that would let my macro detect the platform it's running on.
>
> Is there an easy way to detect the OS from in a macro, so I can  
> substitute in the correct punctuation?  I assume that ImageJ is  
> aware of its environment, but how do I ask it?

Use the File.separator() function to get the file path separator,  
which is "/" on Macs and Linux and "\\" on Windows. Note that the  
getDirectory() macro function returns a file path that ends with a  
path separator.

Use

    if (getInfo("os.name")=="Mac OS X")
       print("This is a Mac")

or

    if (call("ij.IJ.isMacintosh")=="true")
       print("This is a Mac")

to test to see if you are running on a Macintosh.

-wayne