Sample Code

All documentation is preliminary and subject to change

Setup

Setup for Visual Basic 6 or VBA

For both Visual Basic 6 and VBA you must register the SICI Dynamic Link Library. To do this:

  1. Choose Project>References
  2. Check the "SKY Index Communications Interface" checkbox.
  3. Click OK

Setup for Visual Basic .NET

You must register the SICI DLL with your project in order to call the methods in that library. To do that,  you need to:

  1. Choose Project>Add a reference
  2. Click Browse
  3. If you have a 64 bit computer: Navigate to C:\Program Files (x86)\Common Files\SKY Software
  4. If you have a 32 bit computer: Navigate to C:\Program Files\Common Files\SKY Software
  5. Choose SICI10.DLL
  6. Click OK

Using the IndexRows Collection (modifying the entire index)

Some interface utilities will want to loop through all records (rows) in the index and depending upon what is contained in those rows, perform some action. The standard interface routines for moving through the grid can be used for this, but they are much too slow to be useful for a large index. In order to allow for much faster processing of the index, an IndexRows collection has been included. The IndexRows collection was implimented with two classes. One is named IndexRows and the other is IndexRow. The IndexRows class is a collection (array) of IndexRow. The IndexRow class includes properties that allow reading and in most cases editing the fields of an index row.  It also allows you to mark a row for deletion.

If you call the Interface function LoadIndexRows, The interface will query SKY Index for every row in the index and will load those rows into the IndexRows collection. You can then loop through the rows in memory as you would with an string array. You can read the contents of all fields, and edit most of them. The IndexRow class contains the following properties:

Field Attributes
Record (String) [r]
Main (String) [r/w]
Sub1 (String) [r/w]
Sub2 (String) [r/w]
Sub3 (String) [r/w]
Sub4 (String) [r/w]
Sub5 (String) [r/w]
Sub6 (String) [r/w]
Page (String) [r/w]
Label (Long) [r/w]
Selected (Boolean) [r/w]
DateCreated (String) [r]
DateEdited (String) [r]
CreatorInitials (String) [r]
EditorInitials (String) [r]
Deleted (Boolean) [r/w]

Those properties marked with [r] are readonly and those marked with [r/w] can be both read and written.

Note: Changes you make to these properties do not get transfered to the actual SKY Index database until you call the CommitRowChanges function.

Example1: Change the subheading of a row to uppercase if the main heading starts with a capital 'S'

Note that, in this example, the subroutine makes use of the For Each ... Next construct to make it somewhat easier to loop through the entire array. When using this construct, the 'Row' variable will point to the current row during each iteration of the loop.

Sampe code for Visual Basic 6 or VBA

Public Sub Example1

   Dim CI as new SICI10.Interface ' Create an SICI10 Object
   Dim Row As IndexRow ' Define a variable that will be used to point to the current Row

   If Not CI is Nothing Then ' If you are able to create the SKY Index Communications Interface

      If CI.RequestConnection Then ' Request a connection to SKY Index

         If CI.LoadIndexRows Then ' Load a copy of all rows in the SKY Index database

            For Each Row in CI.IndexRows ' Loop through all (each) row of the index looking for main headings that start with capital 'S'
               If Left(Row.Main, 1) = "S" Then
                  Row.Sub1 = Ucase(Row.Sub1) ' Capitalize the entire subheading
               End If
            Next

            ' Commit all changes that you've made to the index
            If Not CI.CommitRowChanges("Subs with uppercase 'S' to uppercase") Then
               Msgbox "An error occurred while saving changes made by <add-in name>. Please check your index for integrity."
            End If

         Else
            MsgBox "<add-in name> was unable to access the index. The operation failed."
         End If

         If Not CI.CloseConnection Then ' Close the connection to SKY Index
            Msgbox "<add-in name> was unable to close the connection to SKY Index. It is recommended that you close and re-open SKY Index to assure stable operation."
         End If

      Else
         Msgbox "<add-in name> was unable to establish a connection to SKY Index. The operation failed."
      End If
   Else
      Msgbox "<add-in name> was unable to perform the desired operation."
   End If

End Sub

Sample Code for Visual Basic .NET

Public Sub Example1

   Dim CI as new SICI10.Interface ' Create an SICI10 Object
   Dim Row As SICI10.IndexRow ' Define a variable that will be used to point to the current Row

   If Not CI is Nothing Then ' If you are able to create the SKY Index Communications Interface

      If CI.RequestConnection Then ' Request a connection to SKY Index

         If CI.LoadIndexRows Then ' Load a copy of all rows in the SKY Index database

            For Each Row in CI.IndexRows ' Loop through all (each) row of the index looking for main headings that start with capital 'S'
               If Strings.Left(Row.Main, 1) = "S" Then
                  Row.Sub1 = Ucase(Row.Sub1) ' Capitalize the entire subheading
               End If
            Next

            ' Commit all changes that you've made to the index
            If Not CI.CommitRowChanges("Subs with uppercase 'S' to uppercase") Then
               Msgbox "An error occurred while saving changes made by <add-in name>. Please check your index for integrity."
            End If

         Else
            MsgBox "<add-in name> was unable to access the index. The operation failed."
         End If

         If Not CI.CloseConnection Then ' Close the connection to SKY Index
            Msgbox "<add-in name> was unable to close the connection to SKY Index. It is recommended that you close and re-open SKY Index to assure stable operation."
         End If

      Else
         Msgbox "<add-in name> was unable to establish a connection to SKY Index. The operation failed."
      End If
   Else
      Msgbox "<add-in name> was unable to perform the desired operation."
   End If

End Sub

Example2: Create a group from all rows that match a specific range of date plus time.

Note that, in this example, the subroutine makes use of the For Each ... Next construct to make it somewhat easier to loop through the entire array. The next example uses a variable to reference each member of the IndexRows collection.

Public Sub Example2()

   Dim i As Long
   Dim RecNos As String
   Dim ToTime As Double
   Dim FromTime As Double
   Dim CreatedTime As Double
   Dim CI As New Interface
   Dim CurRow As IndexRow

   If Not CI Is Nothing Then ' Make sure the Interface object was created

      If CI.RequestConnection Then ' Request a connection to SKY Index

         CI.LoadIndexRows ' Load all rows from the current index into the IndexRows collection

         If ValidateTimes() Then ' Validation code is up to you

            ' Set a 'Double' variable to the value of the date and time so that we can do a comparison (Get the values from textboxes in your form)
            ToTime = Val(txtToYear.Text & txtToMonth.Text & txtToDay.Text & txtToHour.Text & txtToMinute.Text & txtToSecond.Text)
            FromTime = Val(txtFromYear.Text & txtFromMonth.Text & txtFromDay.Text & txtFromHour.Text & txtFromMinute.Text & txtFromSecond.Text)

            ' Loop through all rows in the IndexRows collection
            For i = 1 To CI.IndexRows.Count

               Set CurRow = CI.IndexRows(i) ' Set CurRow equal to the current row's IndexRow object for easier access to that object

               CreatedTime = CI.ConvertTimeToDouble(CurRow.DateCreated)

               ' If the 'CreatedTime' is within the to and from times, add the record number to a comma separated string variable
               If CreatedTime >= FromTime And CreatedTime <= ToTime Then
                  If Len(RecNos) = 0 Then
                     RecNos = CStr(CurRow.Record)
                  Else
                     RecNos = RecNos & "," & CStr(CurRow.Record)
                  End If
               End If

            Next

            ' If there were records that matched the criteria, group them
            If RecNos <> "" Then
               If CI.GroupOnRecNos(RecNos) Then
                  Unload Me
               Else
                  MsgBox "An error occurred. Group was not created."
               End If
            Else
               MsgBox "An error occurred. Group was not created."
            End If
         Else
            MsgBox "One of the dates or times you entered was in an illegal format. Please correct it and try again."
         End If

         If Not CI.CloseConnection Then
            MsgBox "No response from SKY Index when closing the connection'. Please close and reopen SKY Index to assure proper operation."
         End If
      Else
         MsgBox "Could not establish a connection with SKY Index'. Please close and reopen SKY Index to try to correct this problem."
      End If

   End If

End Sub

Copyright ©, SKY Software. All Rights Reserved  ·  Last update: 11 Jan 2018   ·   Is there a problem with our website? Please report it to: Webmaster  ·  Every effort has been made to ensure accuracy, but we cannot be responsible for misprints.  ·  The SKY Software logo is a registered trademark of SKY Software.  ·  SKY Index is a trademark of SKY Software.  ·  Other products and companies referred to herein are trademarks or registered trademarks of their respective companies or mark holders.