scripting / drummerRFC

A place to post RFCs for people who use and develop in Drummer.
MIT License
11 stars 0 forks source link

Writing to local files from scripts in Electric Drummer #28

Open scripting opened 2 years ago

scripting commented 2 years ago

This came up in another forum. A programmer wants to use Electric Drummer as part of their code build system and needs to be able to write to the local file system. Since E/D runs native this is possible. However Drummer doesn't have any built in verbs to do local file writes. But you can add them.

How to add the localfile.xxx verbs

  1. In Electric Drummer choose Scheduler from the Special files sub-menu of the file menu.

  2. If there isn't already a top-level item in the outline called startup, create it

  3. Under startup type a title, any text will do.

  4. And under that paste the text from this script file.

Pause for a second (so the file can save automatically) before quitting and restarting E/D.

Now you should be able to call localfile.write and localfile.read from your scripts.

gwthompson commented 2 years ago

@scripting -- I created the startup script in Electric Drummer per the instructions above and I am still getting the "localfile is not defined" error.

Here is the startup script: Screen Shot 2022-08-24 at 7 13 23 PM

Here is the script in my scripts menu:

Screen Shot 2022-08-24 at 7 13 46 PM

Here is my Electric Drummer console:

Screen Shot 2022-08-24 at 7 17 55 PM

scripting commented 2 years ago

@gwthompson -- there is a problem, i did what you should do, try a simpler test case, then simplify more, and figure out what i did wrong in the instructions. i did make a mistake, but i want you to start doing more investigation to help me so my job gets a little easier. at the level at which you're capable of working, you should be able to tell me exactly what i did wrong. come on you can do it.

scripting commented 2 years ago

A few hours later...

I debugged it by seeing if I replaced the complicated script with something simpler, and it didn't work either, but that factored out most of what was in the error report.

image

And sure enough in the console when I entered myColors it was undefined.

As an experiment I got rid of the var.

image

Restarted Drummer and this time myColors was defined.

So if you try dropping the var off the assignment to localfiles it'll work.

The reason, I suspect is that with var it creates a local and without it, a global is created, which is what we want.

gwthompson commented 2 years ago

@scripting -- I just got home and saw your message. It worked perfectly!