Has anyone had any experience they can share with creating snippets to be used in ActionScript?
I have been playing around with ActionScript.schclass and have been able to add new keywords, but what I’d really like to do is define a keyword that when entered expands out some other full black of code.
I’ve played around with the token:tag and txt attributes to enter a single line, but I’m not sure where to go from here to get a full block of code across multiple lines to autocomplete. I can get everything to autocomplete if I just stick it all on one line, but not sure there’s a way to properly format it on multiple lines.
I’d make sure you version control anything you do like this since a Console upgrade might overwrite it. If you can share what you have, that would be even better.
I’m not sure if there is any danger in doing this or if there might be any odd consequences. That would be a question for @AlanM
I’d guess that the console autocomplete functionality is meant for just a single line. There may be a way to put a new line character in that single line so that you could have a single line autocomplete end up being multiple lines. I haven’t tried this.
I do see some value in ActionScript snippets, particularly for the average console user, but I generally highly recommend automation using the REST API or Dashboards as the way to achieve similar results but even better.
I know that this is functionality that many have asked for and this seems like an interesting existing solution.
REST API seems like it would be overkill to recreate our content authoring processes to add this feature.
Another nice alternative would be the ability to extend the text editor context menu within the script tab similar to computer list right click extensions.
The only option I see to get ActionScript.schclass to work is to find some way to enter a new line or carriage return without it being picked up as literal text.
Also in case it’s worth anything, the snippet in question is used to add a registry key to denote the success or failure of a task.
We use this to trigger a popup notification to the user that an installation has completed. This was created because you can only display a post-action message to the user with a restart or shutdown and they aren’t conditional on success or failure of the task. The ability to have custom post-action messages on success or failure would be a really nice feature.
In case anyone wants to try this out the solution turned out to be much simpler than I expected. Put the whole thing on one line and use carriage return escape \r
I ended up using token:tag under the keyword section for each snippet.
Like @jgstew said, you’ll need some sort of version control likely since it will probably be overwritten during a console upgrade.
I figured there must be a way to specify a newline, but it is hard to know how without knowing more about the .schclass and lexClass: format or just trying things. I’ve tried to look into this previously and have always had trouble finding info about them.
This is an interesting use, though you can add a registry key with a single line.
Either of these are better options than creating a .reg file and running it. There are even solutions for writing to the current user registry using relevance substitution with the regset commands.
Do you have to restart the console for a new entry in ActionScript.schclass to work?
There should be some slight performance benefit over manually creating files, copying files, running the files, deleting the files… but mostly it looks a lot cleaner and I think creating a .reg file is probably more error prone.
If you are going to take the time to make it easy to reuse, then it would be ideal if what you are reusing is also a very nice way to do it so it serves as an example for those that wish to use it as a basis for something else. I definitely think it matters to worry about the more ideal relevance and actionscript if you are going to start using it a lot in many places, otherwise it will haunt you forever and teach other operators the “wrong way” to do things.
More than a console upgrade could override it. If any management extender gets updated then that can overwrite the file in use as its used to expand any actionscript
In that case, then the best option would be to have a bigfix policy action to append to that file if and only if what you are adding is missing, that way it would get added back automatically. @jonbisch
Another option would be to use an app that does text expansion: