Determine what version of Max is running?

Rodrigo's icon

Is there a way to tell whether a patch is running in Max6 or Max7 from inside the patch? Trying to get a patch looking tidy in both and it's turning out to not be possible so I'm going to load a diff bpatcher depending on which version is running.

Peter Castine's icon

'; max getversion foo' where "foo" is the name of a receive object.

Check the "Controlling Max with messages" bit in the docs. The encoding of the version number is a bit idiosyncratic. I don't know the exact values you'll get off hand, but a bit of experimentation should get you through the night.

Rodrigo's icon

Hmm, Max7 is reporting 1793 and Max6 is 1561.

The help doc says this:
"The word getversion, followed by a symbol used as the name of a receive object, will report the Max version number (e.g. 6.1.3 is reported as 1300) to the named receive object."

That seems like it's saying that it only does the .x.x part of the numbers. I only have the latest version of each installed on my computers so I can't test any other variations but this.

jvkr's icon

After conversion to a hexadecimal number, it becomes more clear: sprintf %x

Rodrigo's icon

Perfect!

Peter Castine's icon

Yeah, when I woke up this morning I said "hex" to myself. Convert to hex and it's obvious.

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

You can use the number object for displaying numbers in hex, btw.

Rodrigo's icon
Max Patch
Copy patch and select New From Clipboard in Max.

I ended up using sprintf and then some rounding math to sort it out.