Created
April 18, 2011 16:49
-
-
Save gsherman/925681 to your computer and use it in GitHub Desktop.
ClearBasic function to Transpose a JavaScript Object Into a List Of Records
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function TransposeJavaScriptObjectIntoListOfRecords( jsObject As Variant, recordType As String, recordFields As List, jsObjectFields As List) As List | |
Dim listOfResults As New List | |
listOfResults.ItemType= "record" | |
Dim oneResultRecord As Record | |
Dim index As Integer | |
Dim numberOfResults As Integer | |
Dim listIndex As Integer | |
Dim oneResult As Object | |
numberOfResults = scriptControl.Run("getNumberOfResults", jsObject) | |
For index = 1 To numberOfResults | |
Set oneResultRecord = New Record | |
oneResultRecord.RecordType = recordType | |
Set oneResult = scriptControl.Run("getResultByIndex", jsObject, index) | |
For listIndex = 0 To recordFields.Count - 1 | |
oneResultRecord.SetField recordFields.ItemByIndex(listIndex), getProperty(oneResult, jsObjectFields.ItemByIndex(listIndex)) | |
Next listIndex | |
listOfResults.AppendItem oneResultRecord | |
Next index | |
Set TransposeJavaScriptObjectIntoListOfRecords = listOfResults | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment