Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Storing variable in for loop
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Storing variable in for loop

 Post Reply Post Reply
Author
bootcom View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 February 2005
Location: United Kingdom
Status: Offline
Points: 259
Post Options Post Options   Thanks (0) Thanks(0)   Quote bootcom Quote  Post ReplyReply Direct Link To This Post Topic: Storing variable in for loop
    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
%>

 
Back to Top
bootcom View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 February 2005
Location: United Kingdom
Status: Offline
Points: 259
Post Options Post Options   Thanks (0) Thanks(0)   Quote bootcom Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.