Last updated on September 15th, 2015
With the latest service build (7.1.67) of PrimalScript 2015 we introduced a new feature; custom PrimalSense. While many items in a script can be determined dynamically based on context and offered as a selection in a list, there are equally as many items that are tied to your specific environment or your business logic. There is simply no way we can foresee these items and offer them as you need them.
What we can do however, is to enable you to customize PrimalSense and create your own lists, based on your needs and your environment.
Invoking these custom lists is really easy. Type the name of the list and press Ctrl + L, as in List and it will show up. Lists are stored in this folder: C:\ProgramData\SAPIEN\PrimalScript 2015\Lists. The file name designates the name of a list. To make this feature as flexible as possible, we have designed this with three different types of lists.
1. Static list.
The data for this list is stored in a CSV file or an XML file. For just a simple, single selection list only the data file is required.
2. Cached list.
A configuration file (.ini) contains a command to generate the data file for this list (CSV or XML). The command is only executed ONCE per PrimalScript session and the data file is kept around. If you exit PrimalScript and start it again, the command will be executed again. This is very helpful for data that is dynamic, but does not change very often, e.g. available PowerShell modules.
3. Dynamic list.
A dynamic list executes the command you specified each time you invoke that list. The data format once again is either CSV or XML. A good example for this type of list is the “file” example we provided. It lists the folder content of the directory the current file resides in. Since files get created, deleted or renamed all the time, this list has to always use current data.
Ok, so how does the data part work? You can use a CSV file if your data is single line items.
If you have only simple strings, then you do not even need to use commas. Just list your items one per line.
Sometimes you need to provide a little more information or translate some weird strings into something human readable. GUIDs used for DSC resources are a good example. I cannot remember that many numbers nor can I really distinguish them when I see them. So we show a translation that makes sense but insert the GUID when selected
The data file for this is also just a simple CSV file.
The first column contains the human readable string, the second column is an image index (we get to that later) and the third column is the data we want inserted when selected. You can use this translation for a lot of things to simplify selections, file names to full path names, weird SQL table names to more understandable terms e.g. “Customer Table” to “SQLQCust64527872NMA7657”. If you have seen some SQL databases you know what I mean.
Selecting an item inserts the corresponding code into your script.
The XML format is very simple.
The root node is called <List>, each individual item is in an <item> tag. The “Name” attribute defines the string displayed in the list and the “image” attribute defines an index into the list’s images. The text to be inserted is contained within a CDATA section. Please note that you must use a CDATA section, regular text would be ignored.
So now you know how to create simple static lists to insert simple strings or even multi-line text. Next time I will show you how to make these lists multi-select and how to associate a collection of images with your list.