News combit Dev Blog

Scripting Support in Functions

Posted: Wednesday, October 7, 2015 | 2 comment(s)
 
List & Label has a very powerful formula language. Most manipulations one could think of are possible out of the box or can be realized by using a user defined designer function. However, the latter requires you as a developer to think of the need before deploying your application. In LL21, we'll introduce a new feature that allows to use C# or scripting host languages like VBScript directly in the function wizard.

This vastly extends the power of List & Label expressions, of course. As a script can introduce arbitrary security problems, this is an opt-in feature only – your application has to set a corresponding option in order to get scripting support. It's easy:

 LL.Core.LlSetOption(LlOption.ScriptingEngineEnabled, 1); 
Once this option is set, you can use the Script$() function in the Designer as follows:
 

New feature of version 21


A more advanced application could be a script to count the number of work days between two dates – provided you have a map of public holidays, it's simply the number of days that are not (depending where you live, of course) Saturday or Sunday or public holiday. So you simply loop through all days, check if they are in your holiday map or weekend days and – if not – increment your counter by one. This is something that would not be possible with LL's own expression language as it doesn't support any looping (yet :) ). Also, you probably don't want to edit such a script in the function wizard directly as it doesn't have Autocomplete or Intellisense for C# Scripts (yet :) ). The solution is simple – you just include a file that you can create in the editor of your choice. You include it by using the LoadFile$() function like

Script$("CSharpScript",LoadFile$(ProjectPath$()+"WorkingDaysSample.cs"))
By including a pragma you can even configure your favorite debugger to fire up upon script execution and debug your script using all of Visual Studio's glory:
 

New feature of version 21


I'm really curious to see what you guys will do with this feature. Oh, and by the way, this was one of the highest voted suggestions in our feedback portal. You asked and we listened.




Author: Jochen Bartlau
Head of Development List & Label

Jochen Bartlau leads the development at combit as Managing Director. He's a Microsoft .NET enthusiast driving innovation & agile project management. The mobile devices geek who used to be a physicist in his first life loves to spend his spare time with his family.


  

+1 800 256 3608 (toll-free North America only)