
ASP queue???
I'm trying to find a way to make/use a queue implemented with a linked list instead of an array. Can this be done by making an ASP component or would it be better handled in VB making a COM object (.dll)? Or is there a VB/VBScript queue already out there?<BR>Feel free to answer me at mgb3763@cis.ksu.edu<BR>Thanks guys,<BR> Matt

RE: ASP queue???
You can use either JavaScript objects or instances of VBScript classes to create a linked list in ASP without resorting to a component (DLL).<BR><BR>For example:<BR><BR><%<BR>' In VBScript<BR>Class ListElement<BR> Public Next, Prior<BR> Public Value<BR><BR> Public Sub ClassInitialize( )<BR> Next = null<BR> Prior = null<BR> Value = null<BR> End Sub<BR>End Class<BR><BR>Class LinkedList<BR><BR> Public Head, Tail, Current<BR><BR> Public Sub ClassInitialize( )<BR> Head = Null<BR> Tail = Null<BR> Current = Null<BR> End Sub<BR><BR> Public Sub Add( What )<BR> Dim temp<BR> Set temp = New ListElement<BR> If isNull( Head ) Then<BR> ' first element in list<BR> Set Head = temp<BR> Set Tail = temp<BR> Else<BR> ' not first...add to linked list<BR> Set temp.Prior = Tail<BR> Set Tail.Next = temp<BR> Set Tail = temp<BR> End If<BR> ' we put either objects or simple values into our linked list!<BR> If isObject( What ) Then<BR> Set temp.Value = What<BR> Else<BR> temp.Value = What<BR> End If<BR> End Sub<BR><BR> ' get first item in list...<BR> Public Function First( )<BR> If isNull( Head ) Then<BR> First = Null<BR> Exit Function<BR> End If<BR> Set Current = Head<BR> If isObject( Current.Value ) Then<BR> Set First = Current.Value<BR> Else<BR> First = Current.Value<BR> End If<BR> End Function<BR><BR> ' get next item in linked list...<BR> Public Function GetNext( )<BR> If isNull( Current ) Then<BR> GetNext = Null<BR> Exit Function<BR> End If<BR> If isNull( Current.Next ) Then<BR> Current = Null ' say we are at end<BR> GetNext = Null<BR> Exit Function<BR> End If<BR> Set Current = Current.Next<BR> If isObject( Current.Value ) Then<BR> Set First = Current.Value<BR> Else<BR> First = Current.Value<BR> End If<BR> End Function<BR><BR>End Class<BR>%><BR><BR>That code is 100% untested and I haven't used VBS classes much, so be careful of it. The ideas are correct, but I worry about whether isNull, for example, will work the way I want it to here.<BR><BR>Anyway, to use that LinkedList class, you could do:<BR><BR><%<BR>Set myList = New LinkedList<BR>myList.Add "A string is first"<BR>myList.Add 2<BR>myList.Add Now<BR>...<BR>' now to retrieve the list...<BR>'<BR>val = myList.First<BR>Do Until isNull( val )<BR> Response.Write "Item from list: " & val & "<BR>"<BR> val = myList.GetNext<BR>Loop<BR>...<BR>%><BR><BR>An yway, use that all with caution, but I think the concepts are okay.<BR><BR>
Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts

Forum Rules

