How do I run a script on startup of a specific file

I have a script that checks for updates on a FTP server & updates some materials automatically.

Now I want it to run at startup of a specific max file. I know I can place it in certain folders as Startup Scripts, but then they'll run on every startup.

Any ideas
Eran?

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Gindin's picture

Hi Ofer,    Thanks for the

Hi Ofer,

 

 Thanks for the help, I already went with the callbacks.addScript route. Works fine.

 

Great to see someone from Israel :-)

& some great scripts on your site

 

Thanks

Eran 

Ofer Zelichover's picture

Hi,   If I understand you

Hi,

 

If I understand you correctly, you wish to run the script every time a specific file is opened. If so, I would do it like so:

First, you will have save save some variable with the file. There are a few way to do this:

1. Use appData. e.g. setAppData globalTracks 654321 "update from ftp"

2. Use a persistent global variable. e.g. persistent global g_UpdateFromFTP = true

3. Use a custom attribute on a global track.

I would use the appData method, as persistent globals had issues in older versions of max. It should be safe to use them since max 8, though.

 

Next, write a small script that will be placed in the scripts/startup folder. This script should look something like:

(

callbacks.addScript #filePostOpen "if getAppData globalTracks 654321 == \"update from ftp\" then fileIn \"path/to/your/script.ms\"" id:#updateFromFTP

-- Or if you used the persistent global option use the following: 

--callbacks.addScript #filePostOpen "if g__UpdateFromFTP == true then fileIn \"path/to/your/script.ms\""
id:#updateFromFTP

 

 

hOpe this helps,

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.