﻿
// Declare the namespaces
if (Kinsail.RecordSet == null || typeof(Kinsail.RecordSet) != "object") {Kinsail.RecordSet = new Object();}

Kinsail.RecordSet = {

    // JavaScript record set handling functions
    CreateRecordset: function (RecordsetAsString) {
	    // just split the recordset into an array
	    // each row of data is separated by a pipe "|"
	    // the first row should have the column names, with no commas
	    Recordset = RecordsetAsString.toString().split("|");
	    return Recordset;
    },
    
    GetData: function (JSRecordset, RowNumber, ColumnName, Delimiter) {
        if (Delimiter == null) {
            Delimiter = strDelimiter;
        }
        // set the found location to -1
        intFoundLocation = -1;
        // first, we need to figure out which column we want
	    // to do this, we need to find the column name in the first row (index = 0)
	    ColumnsArray = JSRecordset[0].toString().split(Delimiter)
	    for (intGetDataLoop=0;intGetDataLoop<ColumnsArray.length;intGetDataLoop++) {
	        if (ColumnName.toUpperCase() == ColumnsArray[intGetDataLoop].toUpperCase()) {
                intFoundLocation = intGetDataLoop;
                break;
            }
        }
	    if (intFoundLocation == -1) {
	    	return "ERROR";
	    }
	    else {
	        return JSRecordset[RowNumber].toString().split(Delimiter)[intFoundLocation];
	    }
    }
    
}; // end Kinsail.RecordSet namespace