robertb_NZ
Well-known member
I am using a LinkedList(OF String) to build up a program. Like sticking post-it's in a book, I keep track of where I want to put further statements by saving nodes: -
This all works beautifully: it's very easy to insert data where I want with (for example)
PROVIDED that I use the correct node and don't mess up my logic! Of course I HAVE messed up my logic :blue:, and so I'm trying to debug it. I need to know where the saved marker nodes (like EndInputStats) are pointing. I wrote a little diagnostic routine: -
But Comment stays stubbornly blank. I tried
This doesn't help. (reasons were obvious when I thought about it). I tried changing the loop to
but this won't compile, throwing message
I can't find any property of LinkedListNode(OF String) that tell me its LinkedList index, nor a way to return a LinkedListNode from Program so that I could use IS. To make any of the comparisons work I have to use the node's value, but this gives me the string value and even if this, Previous, and Next nodes all have the same string values as Program (IX), Program(IX-1), and Program(IX+1) this does not prove that the node IS Program(IX).
Can somebody tell me the answer? Thank you, Robert.
Dim Program As New LinkedList(Of String) Dim line As LinkedListNode(Of String) = Program.AddFirst("PROGRAM " & Name & " BATCH;") Dim EndInputStats, EndOutputStats, OutputStmts, WriteStmt As LinkedListNode(Of String) Input = Genrlxls.Input line = Program.AddAfter(line, "COPY " & Input & ";") Output = Genrlxls.Output line = Program.AddAfter(line, "COPY " & Output & ";") ' Generate Structure for Copy-Stats line = Program.AddAfter(line, "DEFINE Copy-Stats DATA(") line = Program.AddAfter(line, "INPUT GROUP,") line = Program.AddAfter(line, "Count INTEGER,") line = Program.AddAfter(line, "END GROUP,") EndInputStats = line line = Program.AddAfter(line, "OUTPUT GROUP,") line = Program.AddAfter(line, "Count INTEGER,") line = Program.AddAfter(line, "END GROUP;") EndOutputStats = line
This all works beautifully: it's very easy to insert data where I want with (for example)
Program.Addbefore(EndInputStats, "Counter1 SMALLINT,");
PROVIDED that I use the correct node and don't mess up my logic! Of course I HAVE messed up my logic :blue:, and so I'm trying to debug it. I need to know where the saved marker nodes (like EndInputStats) are pointing. I wrote a little diagnostic routine: -
Sub DebugProgram(Program As LinkedList(Of String), OutputStmts As LinkedListNode(Of String)) Dim Comment As String For IX = 0 To Program.Count If OutputStmts.Equals(Program(IX)) Then Comment = "<= OutputStmts" Else Comment = "" End If Debug.Print(Program(IX) & Comment) Next End Sub
But Comment stays stubbornly blank. I tried
If OutputStmts IS Program(IX)
This doesn't help. (reasons were obvious when I thought about it). I tried changing the loop to
For Each LLN As LinkedListNode(Of String) In Program
but this won't compile, throwing message
Value of type 'String' cannot be converted to 'System.Collections.Generic.LinkedListNode(Of String)'.
I can't find any property of LinkedListNode(OF String) that tell me its LinkedList index, nor a way to return a LinkedListNode from Program so that I could use IS. To make any of the comparisons work I have to use the node's value, but this gives me the string value and even if this, Previous, and Next nodes all have the same string values as Program (IX), Program(IX-1), and Program(IX+1) this does not prove that the node IS Program(IX).
Can somebody tell me the answer? Thank you, Robert.
Last edited by a moderator: