six demon bag

API documentation is nice, and being able to generate it from the code is even nicer. However, unlike Perl, Python, Java, or several other languages, VBScript doesn't have a feature or tool that supports this. Which kinda sucks.

I tried VBDOX, but didn't find usability or results too convincing. I also tried doxygen by adapting Basti Grembowietz' Visual Basic doxygen filter. However, doxygen does a lot of things I don't actually need, and I didn't manage to make it do some of the things I do need. Thus I ended up writing my own VBScript documentation generator.

If you have a DataTable object in PowerShell and you want to persist that object as a file (and restore it back to a DataTable object sometime later) the naïve approach would be to export the (tabular) data to a (tabular) CSV:

$dt | Export-Csv -Path 'C:\path\to\table.csv' -NoType

However, the problem with this approach is that you lose the type information for the columns of the datatable (the only type information saved by the Export-Csv cmdlet is about the type of the objects representing the rows). Also, there's no simple way to restore the CSV back to a datatable.

VBScript arrays can be created with fixed or dynamic size. Fixed size arrays are rather straightforward. Define Dim var(4) and you have an array variable var with 5 elements (indexes 0 through 4). Unfortunately dynamic arrays aren't quite as simple.

Although VBScript does support arrays, their handling leaves a lot to be desired. To deal with the shortcomings of the built-in arrays (or rather, to avoid having to deal with them) I wrote CArray, a wrapper class that provides operations like inserting, appending and removing elements, getting slices (sub-arrays), sorting, etc.