Print Page | Close Window

Storing variable in for loop

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=14777
Printed Date: 30 March 2026 at 6:55am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Storing variable in for loop
Posted By: bootcom
Subject: Storing variable in for loop
Date Posted: 21 April 2005 at 1:41am
Here is the code for one of my pages. The code reads in an XML sheet, and then loops through each record looking for text that is read in via form. I want it to set a variable (blnIsEmote) to true, this is something i've done hundreds of times but I guess Im sleep deprived at the moment or something cos I can't see where Im going wrong.
 
There is a match in the strings but it's set it to false Cry
 
Someone please help me see the error of my ways Tongue
 

<%   
Dim xmldoc,nodeList,node,i,j
    
'create and load your xml document
Set xmldoc = Server.CreateObject("Microsoft.XMLDOM")
xmldoc.async = false    
xmldoc.load(Server.MapPath("/portal/chat/chat_emotes.xml"))
    
'check for errors
'P/S: you can also validate here against your schema    
if xmldoc.parseError.errorCode=0 Then
        
'create a list of all plants
Set nodeList = xmldoc.documentElement.getElementsByTagName("emote")
                &nbs p;   
  'navigate list and print records   
for i = 0 to xmlDoc.documentElement.childNodes.length -1

Set node = nodeList(i)

response.Write(node.ChildNodes(2).Text & " " & cInt(node.ChildNodes(1).Text) & "<br>")

x = len(node.ChildNodes(2).Text)
               
' Check whether or not this emote is the one that has been keyed in .....
If left(msg, x) = trim(lcase(node.ChildNodes(2).Text)) then

' Strip out the actual emote
tempUsername = replace(lcase(msg), trim(lcase(node.ChildNodes(2).Text)), "")
' Make sure we only keep in the name of the user the emote is for
tempUsername = trim(tempUsername)

' Now check to see whether this is an admin only emote
If cInt(node.ChildNodes(1).Text) = 1 then

' Only allow admins to use admin emotes
If blnAdmin = True then

blnIsEmote = True  ' Set the is emote variable to true
strTempMsg = node.ChildNodes(4).Text

' Strip out the nasty stuff from the variable :-D
msg = replace(strTempMsg, tempUsername, strusername)

' End admin only check
End If

' Check to see whether or not this is a moderator emote
ElseIf cInt(node.ChildNodes(1).Text) = 3 then

' Only allow admins/mods to use mod emotes
If blnAdmin OR blnModerator then

blnIsEmote = True  ' Set the is emote variable to true
strTempMsg = node.ChildNodes(4).Text

' End admin/mod only check
End If

' If this is an emote for any other user group
Else

' Now check that the user is actually authorised to type the emote
If intGroupID => cInt(node.ChildNodes(1).Text) then

blnIsEmote = True  ' Set the is emote variable to true


' Or if  the user is not authorised to view the emote return a bot message to them
Else

' End the authorisation check for this emote
End If

' End check to see if this is for an administrator/ any other user group
End If
    
' End check to see whether the emote is the one that has been keyed in
End If    
    
Next            
                &nbs p;    
'clear objects & free memory
Set node = Nothing
Set nodelist = Nothing

' If there is an error with the XML then we need to write that out and show to the user
Else
   msg = "<font color=red>" & replace(xmldoc.parseError.reason, """", "\""") & "</font>"
End If    

'clear objects & free memory
Set xmldoc = Nothing

If blnIsEmote = true then
response.Write("true")
Else
response.Write("false")
End If
%>

 



Replies:
Posted By: bootcom
Date Posted: 21 April 2005 at 2:02am
LOL its typical. I struggle for 2 hours, post for help on here and find the error straight away.
 
Sorry guys



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net