PrimalScript adds Custom PrimalSense (Part 2: Images and multiple selection)

September 16th, 2015 by Alex Riedel
Last updated on September 15th, 2015


With the latest service build (7.1.67) of PrimalScript 2015 we introduced a new feature; custom PrimalSense. In the first part of this series we showed you how to create a simple list and what options you have for providing data for these lists. If you missed the post, click here.

If your list has just a single type of items an image is not really necessary, but if you have different types, it would be nice to give these items a visual distinction.
Let’s take a look at the ‘machines’ example that gets installed with PrimalScript.


We have different icons for workstations and network servers in this example, so let’s see how this is done.
The data file, machines.csv, has the same basic setup with the strings and an image index for each item.


This time however we also have an additional configuration file, machines.ini. As you can probably guess the file’s base names (machines) tie them together.


The format of this is very simply, I am sure you can figure out what item controls what setting. The important part now is the ‘imagelist’ entry.
It points to a file called icons.bmp.


As you can see index 0 and 4 are the icons we see in our example. These bitmap files contain image that are 16 by 16 pixels, that is what PrimalScript uses for PrimalSense lists.
They are bitmap files (BMP) because that is what Microsoft Windows wants for list control image lists. Last but not least, the background (RGB value 255,0,255) is what is mapped to transparent. You cannot use jpeg or png files here, sorry.

Another setting you can see in this sample ini file is that multiselect is set to 1. That is what makes the checkboxes show up. Normally PrimalSense lists are single select. You select and press Enter to insert the item chosen. If you have computer names, you may need more than one, so you can check the ones you want, press Enter and all items checked get inserted. The separator, which defaults to a space, is used to concatenate the items into a string.

It is all very simple. As an exercise, look at the functions.xml file we provided and make it multi-select. This way you can select the functions you want to insert into your code. With a little work you can make this into a poor man’s code wizard that inserts the standard functions you need for a new script. Think of it as a selective snippet.

In the next part of this series I will show you how you can make these lists dynamic and generate data on the fly.


[Google+]   [Facebook]   [LinkedIn]   [StumbleUpon]   [Digg]   [Reddit]   [Google Bookmark]  

Tags: , , , , ,