how to tell, Mac or Windows?

Feb 6, 2007 at 4:54pm

how to tell, Mac or Windows?

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

#30147
Feb 6, 2007 at 5:05pm

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

#95758
Feb 6, 2007 at 5:21pm

#95759
Feb 6, 2007 at 6:33pm

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 ===

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 180 275 259 196617 < - Calculate offsets. Watch order of
calculation!;
#P newex 230 293 27 196617 &&;
#P newex 14 360 27 196617 gate;
#P comment 287 323 73 196617 After offsets;
#P window linecount 0;
#P message 223 340 153 196617;
#P window linecount 1;
#P newex 223 320 60 196617 prepend set;
#P comment 131 148 73 196617 Before offsets;
#P window linecount 0;
#P message 51 165 153 196617;
#P window linecount 1;
#P newex 51 144 60 196617 prepend set;
#P window linecount 2;
#P comment 334 382 213 196617 Permission to use and redistribute free
of charge granted herewith.;
#P window linecount 1;
#P comment 334 370 213 196617 Copyright 2004-06 Peter Castine.;
#P comment 19 3 244 196617 Bang to trigger recalculation of window
coordinates.;
#P window linecount 2;
#P comment 313 241 207 196617 Offset coordinates relative to
initialization arguments.;
#P window linecount 1;
#P newex 275 242 29 196617 – $2;
#B color 6;
#P newex 230 242 29 196617 – $1;
#B color 5;
#P window linecount 2;
#P comment 31 380 145 196617 Messages to thispatcher in mother patch
go here.;
#P comment 51 114 153 196617 Messages from thispatcher in mother
patch arrive here.;
#N comlet Bang to trigger window repositioning;
#P inlet 1 2 15 0;
#P window linecount 3;
#P comment 313 193 207 196617 Calculate how much to offset window in
order to have the visible top left flush with the top corner of the
(usable) screen.;
#P comment 292 49 149 196617 Kludgy way to determine host OS (and
from that , what the window frame looks like).;
#P window linecount 2;
#P message 31 320 147 196617 window size $1 $2 $3 $4 , window exec;
#P window linecount 1;
#P newex 31 297 127 196617 pack 0 0 0 0;
#P newex 148 273 27 196617 !-;
#B color 14;
#P newex 109 273 27 196617 !-;
#B color 12;
#P newex 70 273 27 196617 -;
#B color 6;
#P newex 31 273 27 196617 -;
#B color 5;
#P newex 275 217 27 196617 -;
#B color 6;
#P newex 230 218 27 196617 -;
#B color 5;
#P newex 247 191 55 196617 unpack 0 0;
#P message 389 165 29 196617 0 44;
#P message 301 165 29 196617 5 41;
#P message 247 165 29 196617 4 23;
#P window linecount 2;
#P comment 255 109 42 196617 Must be XP;
#P comment 408 134 59 196617 Must be Mac OS X;
#P button 389 136 15 0;
#P button 301 136 15 0;
#P window linecount 1;
#P newex 301 113 98 196617 split 2048 4095;
#P button 247 138 15 0;
#P newex 247 91 64 196617 split 1 2047;
#P message 247 47 30 196617 sysv;
#P newex 247 68 39 196617 gestalt;
#P newex 30 184 147 196617 unpack s s 0 0 0 0;
#P message 1 47 75 196617 window getsize;
#P button 1 23 15 0;
#N comlet Connect to inlet of thispatcher in the mother patch.;
#P outlet 14 389 15 0;
#P window linecount 2;
#P comment 320 136 61 196617 Must be Mac OS 8 or 9;
#P comment 422 164 124 196617 < - Effective "top left" coordinates for
each OS;
#N comlet Messages from thispatcher object in the mother patch go here;
#P inlet 30 121 15 0;
#P user panel 221 189 301 83;
#X brgb 125 125 255;
#X frgb 0 0 0;
#X border 1;
#X rounded 0;
#X shadow 0;
#X done;
#P user panel 240 38 233 124;
#X brgb 125 255 125;
#X frgb 0 0 0;
#X border 1;
#X rounded 0;
#X shadow 0;
#X done;
#P window linecount 1;
#P comment 334 358 213 196617 lp.doom is part of the Litter Power
Package.;
#P connect 16 0 21 0;
#P connect 14 1 16 0;
#P connect 15 0 20 0;
#P connect 14 0 15 0;
#P connect 12 1 14 0;
#P connect 22 1 24 1;
#P connect 24 0 37 0;
#P lcolor 7;
#P fasten 9 3 26 0 116 235 75 235;
#P lcolor 7;
#P fasten 9 3 24 0 116 211 280 211;
#P lcolor 7;
#P fasten 37 0 26 1 280 265 92 265;
#P lcolor 7;
#P fasten 37 0 28 0 280 265 153 265;
#P lcolor 7;
#P fasten 37 0 49 1 280 293 252 293;
#P lcolor 7;
#P connect 22 0 23 1;
#P fasten 21 0 22 0 394 183 252 183;
#P fasten 20 0 22 0 306 183 252 183;
#P connect 19 0 22 0;
#P connect 13 0 19 0;
#P connect 12 0 13 0;
#P connect 10 0 12 0;
#P connect 11 0 10 0;
#P connect 7 0 8 0;
#P fasten 7 0 11 0 6 43 252 43;
#P fasten 36 0 25 1 235 261 53 261;
#P lcolor 6;
#P fasten 36 0 27 0 235 261 114 261;
#P lcolor 6;
#P fasten 36 0 49 0 235 290 235 290;
#P lcolor 6;
#P connect 23 0 36 0;
#P lcolor 6;
#P fasten 9 2 25 0 89 215 36 215;
#P lcolor 6;
#P fasten 9 2 23 0 89 215 235 215;
#P lcolor 6;
#P connect 45 0 46 0;
#P connect 29 0 30 0;
#P fasten 29 0 45 0 36 317 228 317;
#P connect 9 5 28 1;
#P lcolor 15;
#P connect 28 0 29 3;
#P lcolor 15;
#P fasten 9 4 27 1 143 263 131 263;
#P lcolor 13;
#P connect 27 0 29 2;
#P lcolor 13;
#P connect 26 0 29 1;
#P lcolor 7;
#P connect 42 0 43 0;
#P connect 3 0 9 0;
#P fasten 3 0 42 0 35 141 56 141;
#P connect 30 0 48 1;
#P connect 25 0 29 0;
#P lcolor 6;
#P connect 48 0 6 0;
#P fasten 8 0 6 0 6 384 19 384;
#P fasten 49 0 48 0 235 312 182 312 182 353 19 353;
#P connect 33 0 7 0;
#P window clipboard copycount 51;

————– 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

#95760
Feb 7, 2007 at 10:38am

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.

#95761
Feb 7, 2007 at 12:30pm

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

#95762
Feb 7, 2007 at 12:47pm

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.

#95763
Feb 7, 2007 at 12:58pm

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

#95764
Feb 7, 2007 at 12:59pm

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

#95765
Feb 7, 2007 at 2:23pm

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.

#95766
Feb 7, 2007 at 4:09pm

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

#95767
Feb 7, 2007 at 7:36pm

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.

#95768
Feb 7, 2007 at 10:59pm

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

#95769

You must be logged in to reply to this topic.