Adding to a Bookmark

The following sub written by Marc Nutter for me worked earlier, but now produces an error:

  Dim Pos1, Pos2 As Integer
  Dim Temp, ThisBN, ThisCN, ThisCNN As String
  Dim TrimXMLLine As String
  TrimXMLLine = Trim ( XMLLine ) 
  If LeftB ( TrimXMLLine, 9 ) = "<ObjName>" _
    And InStr ( XMLLInes ( XMLLineNumber - 1 ) , "<block type=" ) <> 0 Then
    Temp = BetweenTags ( XMLLine, "<ObjName>" ) 
    If Trim ( Temp ) <> "" Then
      If BuildingBookmarks Then /// mn
        If CurrentModule <> Temp Then /// mn
          CurrentBookmark = New Bookmark ( Temp, BookmarkLines ) /// mn
          BookmarksListBox.AddFolder Temp /// mn
          BookmarksListBox.CellTag ( BookmarksListBox.LastIndex, 0 ) = CurrentBookmark
        End If /// mn 
      End If /// mn 
      CurrentModule = Temp
      CurrentControl = ""
      CurrentMenuItem = ""
      CurrentMethod = ""
    End If 
  End If 
  If LeftB ( TrimXMLLine, 12 ) = "<block type=" Then
    BlockNumber = BlockNumber + 1
    ControlNumber = - 1
    Pos1 = 14
    Pos2 = InStr ( Pos1, TrimXMLLine, Q ) 
    Temp = Mid1 ( TrimXMLLine, Pos1, Pos2 - 1 ) 
    If Trim ( Temp ) <> "" Then
      CurrentModule = ""
      ModuleType = Temp
      CurrentControl = ""
      CurrentMenuItem = ""
      CurrentMethod = ""
    End If 
  End If 
  If LeftB ( TrimXMLLine, 17 ) = "<ControlBehavior>" Then
    ControlNumber = ControlNumber + 1
    If ControlNumber > - 1 Then
      ThisBN = Str ( BlockNumber ) 
      If Len ( ThisBN ) = 1 Then ThisBN = "0" + ThisBN
      ThisCN = Str ( ControlNumber ) 
      If Len ( ThisCN ) = 1 Then ThisCN = "0" + ThisCN
      ThisCNN = ThisBN + ThisCN
      CurrentControl = ControlName ( Val ( ThisCNN ) ) 
    End If 
    CurrentMenuItem = ""
    CurrentMethod = ""
  End If 
  If LeftB ( TrimXMLLine, 13 ) = "<MenuHandler>" Then
    Temp = Trim ( XMLLInes ( XMLLineNumber + 1 ) ) 
    Pos1 = 11
    Pos2 = InStrB ( 12, Temp, "<" ) - 1
    CurrentControl = ""
    CurrentMenuItem = Mid1 ( Temp, Pos1, Pos2 ) 
    CurrentMethod = ""
  End If 

This seems to be the particular line which causes the problem:

          BookmarksListBox.AddFolder Temp /// mn

How do I prevent the error (which never occurred before)? Any advice will be much appreciated.

(I no longer know how to get in touch with Marc.)

Warm regards,

Barry Traver

Here’s some additional information regarding what appears at the bottom of the screen in the center…

The Stack column says this:

Window1.GetCurrentInfoS Window1.DoIndent WIndow1.DIsplaySourceCode WIndow1.FinishWithSource Window1.OpenXML WIndow1_mnuOpenXML_Action
If I understand that correctly, it tells the sequence of subs that got the program from start (mnuOpenXML, which is OpenXML on the top menu menu bar) to where it crashed (GetCurrentInfoS). It’s a matter of reading the Stack Column from bottom to top.

The “Va. Variables” column I don’t understand quite as well:

[code] NAME VALUE
Globals
B Bookmark
Exception NilObjectException
Pos1 12
self Window1.Window1

[/code]The significant thing seems to be the “NilObjectException.” I’m not sure why it says “Window1.Window1” rather than simply “Window1.”

Barry Traver