Can you create global functions?

Discuss macro programming, and post any new macros here!
ChrisDuncan
Posts: 379
Joined: Sat Sep 14, 2013 9:35 pm
Location: Atlanta GA / USA / Earth / Milky Way / The 'Verse
Been thanked: 1 time

Can you create global functions?

Post by ChrisDuncan »

Hey, guys.

My coding background is C / C++ / C#, so I'm picking up the Python as I go. Apologies if this is a dumb question.

I'd like to build a library of commonly used routines that I can then call in my other macros. For example, it would be great if I could call a home grown DeslectAll() rather than copying the loop into each macro. Additionally, If I need to change the function I would only have to do it in one place.

If this is possible, where would I put these routines so that they would be available in to all my Dmxis macros?

Thanks!
Christopher Duncan
Author of
Have Fun, Get Paid: How to Make a Living With Your Creativity
http://www.ChristopherDuncan.com
Dave Brown [admin]
Posts: 2123
Joined: Sat Sep 15, 2012 4:53 pm
Has thanked: 5 times
Been thanked: 17 times

Re: Can you create global functions?

Post by Dave Brown [admin] »

Look at System/Startup.py, System/RGB.py and Colours/Blue/Blue.py for an example of a global colour function.

Following this model, you could simply create Chris/CommonStuff.py to contain a bunch of common functions. Then add import Chris/Common.py at the start of your macros to access your global functions.
Dave Brown - db audioware
Author of Show Buddy Setlist | Show Buddy Active | ArtNetMon
ChrisDuncan
Posts: 379
Joined: Sat Sep 14, 2013 9:35 pm
Location: Atlanta GA / USA / Earth / Milky Way / The 'Verse
Been thanked: 1 time

Re: Can you create global functions?

Post by ChrisDuncan »

Thanks, man. I'm really a python newbie.

By the way, can you let me know what the Macro lane exposed in the vst automation does? If it fires a macro based on the value, how do I relate that to the directory structure of macros to tell it to fire a particular one?
Christopher Duncan
Author of
Have Fun, Get Paid: How to Make a Living With Your Creativity
http://www.ChristopherDuncan.com
Post Reply