Don’t worry, we’re not done with form enhancements yet, but I thought I’d take a quick 1-post break from forms stuff to look at some of the new functions coming to DriveWorks Projects in DriveWorks Solo and Pro 8.
In a future blog post I’ll be covering some of the other enhancements to rules including some neat changes to the rules builder, so stay tuned!
When it comes to functions, we got a lot of feedback indicating that you’d like to see better ways of working with lists, file names, and text in general, so in this release we’ve delivered. Here’s a selection of some of the more interesting new functions:
- ListCountItems
- ListFindItem
- ListGetItem
- ListJoin
- FsChangeExtension
- FsGetExtension
- FsGetDirectoryName
- FsGetFileName
- FsPathCombine
- TextFormat
Each of these functions is described briefly below. For anyone that’s interested, the “Fs” prefix on the file name functions stands for “File System”.
Most of these functions are pretty simple and you may even have some of your own if you’ve been using the software for a while, but hopefully adding them as core functionality makes life easer for everyone – and these versions have been built to be as fast as humanly possible.
List Functions
ListCountItems
ListCountItems does precisely what the name indicates – it counts the items in a pipe-delimited list. So for example:
ListCountItems("Hello|World")
Returns 2.
ListFindItem
This function takes a list and an item to find, and returns the index of the item in that list, for example:
ListFindItem("Hello|World|Michael", "World")
Returns 2.
For consistency with table functions, ListFindItem returns #VALUE! if the item isn’t in the list, which can be checked for by using IsError.
ListGetItem
This function takes a list and the index of an item and gets the text of that item from the list, for example:
ListGetItem("Hello|World|Michael", 2)
Returns “World”.
If the index is outside of the range of the list, then “” is returned.
ListJoin
This function takes two lists or items and joins them, for example:
ListJoin("Hello", "World")
ListJoin("Hello|World", "World")
ListJoin("Hello|World", "World|How")
Return “Hello|World”, “Hello|World|World”, and “Hello|World|World|How” respectively.
File Name Functions
FsChangeExtension
This function changes or appends the extension of a file path, for example:
FsChangeExtension("C:\Hello.txt", ".pdf")
FsChangeExtension("C:\Hello", ".pdf")
Both return “C:\Hello.pdf”.
FsGetExtension
This function gets the extension from a file path, for example:
FsGetExtension("C:\Hello.pdf")
Returns “.pdf”
FsGetDirectoryName
This function gets the directory from a path, for example:
FsGetDirectoryName("C:\Hello\World\Report.pdf")
Returns “C:\Hello\World”
FsGetFileName
This function gets the file name from a path, for example:
FsGetFileName("C:\Hello\World\Report.pdf")
Returns “Report.pdf”
FsPathCombine
This function combines two paths, or pieces of paths, for example:
FsPathCombine("C:\Hello", "World\Report.pdf")
Returns “C:\Hello\World\Report.pdf”
Text Functions
TextFormat
This function is probably best explained by way of an example or ten 
TextFormat("http://acme/datasheets/{0}/{1}/datasheet.pdf",
"the-manufacturer", "the-product-id")
This example is pretty simple – the {0}, {1} bits in the first string get replaced with the 2nd, and 3rd parameters. TextFormat can take any number of parameters and numbering starts at zero.
The TextFormat function can also be used to format numbers and dates, for example:
TextFormat("http://acme/datasheets/{0:yyyy-MM-dd}/datasheet.pdf",
DateReturn)
The addition of the text format function is going to make it much easier to build up strings which are built from multiple pieces of data which may or may not need additional formatting performed.
Conclusion
That pretty much concludes this round up of some of the nice little helper functions coming in the next version of DriveWorks, in my next post I’ll get back to covering some of the cool new features in the forms designer.
Philip
Recent Comments