Ok, heres the scenario. I have an array of 3 elements, and I also have a dictionary object called strWords. When I add keywords the dictionary looks for the word 'and' OR the word 'or'. If it finds those words, it DOES NOT ADD THEM. I dont want these words in my dictionary.
That works fine. I then load my array again (by reDim'n by ReDim MyArray(strWords.Count - 1), cuz Arrays are zero based and Dictionarys are 1 based, and if I'm wrong, please let me know. But thats what I've read.
Once that is complete I then load the array from the dictionary through a for loop. This is where I have a problem. For some reason the loop increments automatically, and I dont have a variable to increment. I'm wondering is the Dictionary incrementing my loop? This causes a problem, by loading a 'blank' value or NULL value into one of my array slots. So, if I have an array that says 'dog or cat', it should return an array of 'dog, cat'. This is because at the ADD Procedure filters out the 'and' and the 'or' from the array that is loading the dictionary. I'll post the code below.
If this didnt make any sense, please let me know.
---------------------------------------------
Dictionary ObJect Code
---------------------------------------------
<%
CLASS clsSearchDict
Private KeySearch
Public Sub Class_Initialize
Set KeySearch = Server.CreateObject("Scripting.Dictionary"
End Sub
Public Sub Add(iCnt, word)
If word = "or" OR word = "and" then
'Nothing Happens!! Whooo hooo!!
Else
KeySearch.Add iCnt, word
Response.Write "D - Added: " & word & "<BR><BR>"
End If
End Sub
Public Property Get Count
Count = KeySearch.Count
End Property
END CLASS
%>
------------------
ASP Page Code
-----------------
I'm not going to post all of it, just the part i'm having a problem w/...
'strKeywords is the array that has 3 elements in it (cat, or, dog) this array was constructed from splitting a querystring. The only way i found to properly load the correct amount of elemets is to autoincrement 'i' and then deincrement it. I dont know why its working like that. I have no clue. I've spent over 10 hours trying to debug.
Dim strWords
Set strWords = New clsSearchDict
For i = 0 to UBOUND(strKeyWords)
i = i + 1
strWords.Add (i), strKeyWords(i - 1)
i = i - 1
Next
ReDim strKeyWords(strWords.Count - 1)
For i = 0 to (strWords.Count - 1)
strKeywords(i) = strWords.Item(i + 1)
Response.Write "Still In Dictionary: " & strKeyWords(i) & "<BR><BR>"
Response.Write i & "<BR><BR>"
Next
----------------------------
Thanx,
donn
That works fine. I then load my array again (by reDim'n by ReDim MyArray(strWords.Count - 1), cuz Arrays are zero based and Dictionarys are 1 based, and if I'm wrong, please let me know. But thats what I've read.
Once that is complete I then load the array from the dictionary through a for loop. This is where I have a problem. For some reason the loop increments automatically, and I dont have a variable to increment. I'm wondering is the Dictionary incrementing my loop? This causes a problem, by loading a 'blank' value or NULL value into one of my array slots. So, if I have an array that says 'dog or cat', it should return an array of 'dog, cat'. This is because at the ADD Procedure filters out the 'and' and the 'or' from the array that is loading the dictionary. I'll post the code below.
If this didnt make any sense, please let me know.
---------------------------------------------
Dictionary ObJect Code
---------------------------------------------
<%
CLASS clsSearchDict
Private KeySearch
Public Sub Class_Initialize
Set KeySearch = Server.CreateObject("Scripting.Dictionary"
End Sub
Public Sub Add(iCnt, word)
If word = "or" OR word = "and" then
'Nothing Happens!! Whooo hooo!!
Else
KeySearch.Add iCnt, word
Response.Write "D - Added: " & word & "<BR><BR>"
End If
End Sub
Public Property Get Count
Count = KeySearch.Count
End Property
END CLASS
%>
------------------
ASP Page Code
-----------------
I'm not going to post all of it, just the part i'm having a problem w/...
'strKeywords is the array that has 3 elements in it (cat, or, dog) this array was constructed from splitting a querystring. The only way i found to properly load the correct amount of elemets is to autoincrement 'i' and then deincrement it. I dont know why its working like that. I have no clue. I've spent over 10 hours trying to debug.
Dim strWords
Set strWords = New clsSearchDict
For i = 0 to UBOUND(strKeyWords)
i = i + 1
strWords.Add (i), strKeyWords(i - 1)
i = i - 1
Next
ReDim strKeyWords(strWords.Count - 1)
For i = 0 to (strWords.Count - 1)
strKeywords(i) = strWords.Item(i + 1)
Response.Write "Still In Dictionary: " & strKeyWords(i) & "<BR><BR>"
Response.Write i & "<BR><BR>"
Next
----------------------------
Thanx,
donn