{"id":9860,"date":"2015-09-16T06:00:00","date_gmt":"2015-09-16T13:00:00","guid":{"rendered":"https:\/\/www.sapien.com\/blog\/?p=9860"},"modified":"2015-09-15T09:43:00","modified_gmt":"2015-09-15T16:43:00","slug":"primalscript-adds-custom-primalsense-part-2-images-and-multiple-selection","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2015\/09\/16\/primalscript-adds-custom-primalsense-part-2-images-and-multiple-selection\/","title":{"rendered":"PrimalScript adds Custom PrimalSense (Part 2: Images and multiple selection)"},"content":{"rendered":"<p>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, <a href=\"https:\/\/wp.me\/p3tXTf-2yR\" target=\"_blank\">click here<\/a>.<\/p>\n<p>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.<br \/>\nLet\u2019s take a look at the \u2018machines\u2019 example that gets installed with PrimalScript.<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/09\/image20.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0px;\" title=\"image\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/09\/image_thumb20.png\" alt=\"image\" width=\"308\" height=\"203\" border=\"0\" \/><\/a><\/p>\n<p>We have different icons for workstations and network servers in this example, so let\u2019s see how this is done.<br \/>\nThe data file, machines.csv, has the same basic setup with the strings and an image index for each item.<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/09\/image21.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0px;\" title=\"image\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/09\/image_thumb21.png\" alt=\"image\" width=\"143\" height=\"131\" border=\"0\" \/><\/a><\/p>\n<p>This time however we also have an additional configuration file, machines.ini. As you can probably guess the file\u2019s base names (machines) tie them together.<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/09\/image22.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0px;\" title=\"image\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/09\/image_thumb22.png\" alt=\"image\" width=\"218\" height=\"108\" border=\"0\" \/><\/a><\/p>\n<p>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 \u2018imagelist\u2019 entry.<br \/>\nIt points to a file called icons.bmp.<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/09\/icons.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0px;\" title=\"icons\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/09\/icons_thumb.png\" alt=\"icons\" width=\"640\" height=\"15\" border=\"0\" \/><\/a><\/p>\n<p>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.<br \/>\nThey 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.<\/p>\n<p>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.<\/p>\n<p>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\u2019s code wizard that inserts the standard functions you need for a new script. Think of it as a selective snippet.<\/p>\n<p>In the next part of this series I will show you how you can make these lists dynamic and generate data on the fly.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[582,410,624,21],"tags":[68,1028,1027,37,168,197],"class_list":["post-9860","post","type-post","status-publish","format-standard","hentry","category-feature-peek","category-primalscript-software-news","category-service-build","category-software-news","tag-csv","tag-customize","tag-intellisense","tag-primalscript","tag-primalsense","tag-xml"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/9860","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=9860"}],"version-history":[{"count":3,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/9860\/revisions"}],"predecessor-version":[{"id":9886,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/9860\/revisions\/9886"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=9860"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=9860"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=9860"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}