how to tell, Mac or Windows?

Dan Nigrin's icon

I thought this had been covered in the past, but Google searching the
forum yielded nothing.

What's the easiest/most reliable/best/whatever way to determine from
within a patch whether the patch is running on Mac or on Windows?
shell? javascript? java?

Plug and play examples greatly appreciated!

Dan
--
Dan Nigrin
Defective Records
202 Hack / PC-1600 User / VSTi Host / OMS Convert / Jack OS X / Major
Malfunction
http://www.defectiverecords.com
http://www.jackosx.com

Dan Nigrin's icon

Clicked send to soon - perusing the docs found the answer:

message to max, getsystem

Sorry for the bandwidth.
Dan

At 11:54 AM -0500 2/6/07, Dan Nigrin wrote:
>I thought this had been covered in the past, but Google searching
>the forum yielded nothing.
>
>What's the easiest/most reliable/best/whatever way to determine from
>within a patch whether the patch is running on Mac or on Windows?
>shell? javascript? java?
>
>Plug and play examples greatly appreciated!

--
Dan Nigrin
Defective Records
202 Hack / PC-1600 User / VSTi Host / OMS Convert / Jack OS X / Major
Malfunction
http://www.defectiverecords.com
http://www.jackosx.com

Jean-Francois Charles's icon
Peter Castine's icon

On 6-Feb-2007, at 18:05, Dan Nigrin wrote:
> Clicked send to soon - perusing the docs found the answer:

In case anyone's interested, I developed a method before the ;max
getsystem method existed, which I enclose for the benefit of the
curious (but the curious should at least download the Litter Power
Starter Pack to see it in action)

I still use it because it ain't broke and is obsessively backwards-
compatible.

-- P.

==== Schnipp'n'Save as lp.doom.mxb ===

Max Patch
Copy patch and select New From Clipboard in Max.

-------------- http://www.bek.no/~pcastine/Litter/ -------------
Peter Castine +--> Litter Power & Litter Bundle for Jitter
Universal Binaries on the way
iCE: Sequencing, Recording &
Interface Building for |home | chez nous|
Max/MSP Extremely cool |bei uns | i nostri|
http://www.dspaudio.com/ http://www.castine.de

nick rothwell | project cassiel's icon

On 6 Feb 2007, at 18:33, Peter Castine wrote:

> I still use it because it ain't broke and is obsessively backwards-
> compatible.

An obvious question (and one which has cropped up a few times) would
be: why does it matter whether the code is running on Mac or Windows?

OS-specific dependencies are best avoided; if they *can't* be
avoided, then it's better to think in terms of some abstraction which
specifies whether the current platform "does so-and-so" or "expects
such-and-such" rather than whether it's one or the other. (For
example, Java has little hooks for dealing with OS-specific filenames
in a generic manner, as does Max itself, for that matter.)

Otherwise, if there's ever a Linux port of Max/MSP, what would you
want back as an answer?

And by the way: is a MacBook Pro running Windows XP a "Mac" or
"Windows"? (Or both?)

    -- N.

Dan Nigrin's icon

At 10:38 AM +0000 2/7/07, Nick Rothwell wrote:
>An obvious question (and one which has cropped up a few times) would
>be: why does it matter whether the code is running on Mac or Windows?

Because I'm storing a Preference file to disk, and there are
OS-specific "correct" places to put such files. Thus the need to
know.

Dan
--
Dan Nigrin
Defective Records
202 Hack / PC-1600 User / VSTi Host / OMS Convert / Jack OS X / Major
Malfunction
http://www.defectiverecords.com
http://www.jackosx.com

nick rothwell | project cassiel's icon

On 7 Feb 2007, at 12:30, Dan Nigrin wrote:

> Because I'm storing a Preference file to disk, and there are OS-
> specific "correct" places to put such files. Thus the need to know.

OK - although FWIW (IMHO) that's the wrong approach. Max/MSP should
provide a portable way of putting preference files in the right
place. (As far as I know, it doesn't, so Windows-vs-Mac checking is
probably all you can do.)

    -- N.

Dan Nigrin's icon

At 12:47 PM +0000 2/7/07, Nick Rothwell wrote:
>On 7 Feb 2007, at 12:30, Dan Nigrin wrote:
>
>>Because I'm storing a Preference file to disk, and there are
>>OS-specific "correct" places to put such files. Thus the need to
>>know.
>
>OK - although FWIW (IMHO) that's the wrong approach. Max/MSP should
>provide a portable way of putting preference files in the right
>place. (As far as I know, it doesn't, so Windows-vs-Mac checking is
>probably all you can do.)

I agree - but to my knowledge also, in Java, Javascript, shell or
Max/MSP -- there is no current way to determine that full path - just
the boot volume, user's home directory, etc..

Thanks,
Dan
--
Dan Nigrin
Defective Records
202 Hack / PC-1600 User / VSTi Host / OMS Convert / Jack OS X / Major
Malfunction
http://www.defectiverecords.com
http://www.jackosx.com

Peter Castine's icon

On 7-Feb-2007, at 11:38, Nick Rothwell wrote:

> An obvious question (and one which has cropped up a few times)
> would be: why does it matter whether the code is running on Mac or
> Windows?

In the case of the example at hand: the window frames are different
and I adjust window position to account for this.

If Litter Power had originally been developed for OS X, this probably
would not have been an issue, but I had an historical legacy to deal
with. Rather than tediously reposition 70 windows manually to look
beautiful on OS X suboptimal on Classic, I wrote the abstraction to
adjust position according to host system. When 4.3 came around, I
simply modified the abstraction and was good to go.

But there are plenty of further reasons why OS does matter. Mac OS is
not simply Windows with an Apple logo pasted on top. You have
different externals available for both platforms, as well as
different responses to certain messages. Ever use gestalt in a patch?

It wouldn't surprise me if, when you port registry to Windows, that
there will be some subtle differences in behavior.

Speaking of hell freezing over:

> Otherwise, if there's ever a Linux port of Max/MSP, what would you
> want back as an answer?

I would expect an response different from the responses given for Mac
OS and Windows. Something like 'linux'. The patch I submitted will
handle the situation--not necessarily optimally, but it won't bring
the application to its knees.

> And by the way: is a MacBook Pro running Windows XP a "Mac" or
> "Windows"? (Or both?)

The OS is Windows. Neither my abstraction nor ';max getsystem'
distinguish between Dell, HP, & Co. I don't understand why the Apple
logo on the box should make any difference whatsoever. Apparently
neither does Max.- The getsystem message is reporting the OS.

Admittedly, responding with 'macintosh' instead of, say, 'macos'
tends to obfuscate what's going on. But this is nothing to slow down
the intrepid programmer.

-------------- http://www.bek.no/~pcastine/Litter/ -------------
Peter Castine +--> Litter Power & Litter Bundle for Jitter
Universal Binaries on the way
iCE: Sequencing, Recording &
Interface Building for |home | chez nous|
Max/MSP Extremely cool |bei uns | i nostri|
http://www.dspaudio.com/ http://www.castine.de

nick rothwell | project cassiel's icon

On 7 Feb 2007, at 12:59, Peter Castine wrote:

> In the case of the example at hand: the window frames are different
> and I adjust window position to account for this.

So the right thing would be some kind of API call which returned some
parameters to help with window positioning. (And which would then be
provided on future platforms.)

Ditto for registry: I don't want to know whether it's Mac or Windows
- I want to have (or provide) some bit of API which lets me abstract
over the differences.

I'm not saying that this kind of solution is likely to happen (or is
even remotely possible) - but just that "am I on a Mac or Windows"
is, in principle, not the right question.

Peter Castine's icon

On 7-Feb-2007, at 15:23, Nick Rothwell wrote:

> I'm not saying that this kind of solution is likely to happen (or
> is even remotely possible) - but just that "am I on a Mac or
> Windows" is, in principle, not the right question.

In theory, I agree.

In practice, I have always found "platform independent" to be a myth.
Sorry, I've just had too many disappointments to even dream about
being optimistic.

-- P

"In theory, there is no difference between theory and practice. In
practice, there is."

-------------- http://www.bek.no/~pcastine/Litter/ -------------
Peter Castine +--> Litter Power & Litter Bundle for Jitter
Universal Binaries on the way
iCE: Sequencing, Recording &
Interface Building for |home | chez nous|
Max/MSP Extremely cool |bei uns | i nostri|
http://www.dspaudio.com/ http://www.castine.de

nick rothwell | project cassiel's icon

On 7 Feb 2007, at 16:09, Peter Castine wrote:

> "In theory, there is no difference between theory and practice. In
> practice, there is."

Hmm - either Dijkstra or Knuth. I'd guess the former.

    -- N.

Peter Castine's icon

On 7-Feb-2007, at 20:36, Nick Rothwell wrote:

> Hmm - either Dijkstra or Knuth. I'd guess the former.

Wikiquote cites attributions to Yogi Berra and Jan L. A. van de
Snepscheut (!)

FWIW

-------------- http://www.bek.no/~pcastine/Litter/ -------------
Peter Castine +--> Litter Power & Litter Bundle for Jitter
Universal Binaries on the way
iCE: Sequencing, Recording &
Interface Building for |home | chez nous|
Max/MSP Extremely cool |bei uns | i nostri|
http://www.dspaudio.com/ http://www.castine.de