VBScript allows creating multi-dimensional array which is quite often used as best practice to load recordset in classic asp. However, Multi-dimensional arrays has its own limitation. There is no easy way to query, sort data or even check if the array is empty or null. The solution presented below addresses workaround for filtering two dimensional array.

You may have noticed that if there is no matching data, the function returns nothing. This allows the receiving to code check whether the result is an array or not and continue. Returning an empty array would complicate thing. There is no way to check array is empty other than trapping exception while using resulting empty array. The following code is an example utilizing above function to filter array.

The above example outputs array (id equals 1 and id equals 4) data that matches pid equals 0 .

You can copy above code to a file naming it “filter.vbs ” and run in command line using cscript.exe.

Happy Coding!!!


Classic ASP/VBScript – Filter 2 Dimensional Array
Tagged on:     

Leave a Reply

Your email address will not be published. Required fields are marked *