Striped Fish2 Posted March 28, 2012 Share Posted March 28, 2012 I have a subroutine I have written and when I call it I get this error expected end of statement. Here is the code for the subroutine: Public Sub CreateLinks(xmlcode)set Hero = new cHeroSet XML = Server.Createobject("MSXML2.DomDocument.6.0")XML.LoadXML(xmlcode)endoflinks=0Dim oNodeDo until endoflinks=1For each oNode in XML.SelectNodes("/City/Links/Link")'Checks for the end of links tag and if it finds it exit the loop.If oNode.text = "END OF LINKS" thenendoflinks=1exit subEnd IfsDestination = oNode.getAttribute("destination")'Checks for the header attributeIf sDestination = "#HEADER#" thenEventRequired = oNode.getAttribute("Event")'Checks for an event requirementIf IsNull(EventRequired) thenresponse.write "<b style='color:white'>" & oNode.text & "</b><br />"ElseEventNumber=CInt(EventRequired)If Hero.HaveEvent(EventNumber) thenresponse.write "<b style='color:white'>" & oNode.text & "</b><br />"Elseresponse.write ""End IfEnd If'Checks for a line break (space)ElseIf sDestination = "#SPACE#" thenresponse.write "<br />"ElseEventRequired = oNode.getAttribute("Event")RequiredIfStatement = oNode.getAttribute("requirement")'Checks for an event requirementIf IsNull(EventRequired) thenresponse.write "<a href=""" & Replace(oNode.getAttribute("destination"),"_","&") & """ class=""link""><img src='" & BaseDirectory("images/icons/" & oNode.getAttribute("icon") & "") & "' style='border: 1px solid gold' />" & oNode.text & "</a><br />"ElseEventNumber=CInt(EventRequired)If Hero.HaveEvent(EventNumber) thenresponse.write "<a href=""" & Replace(oNode.getAttribute("destination"),"_","&") & """ class=""link""><img src='" & BaseDirectory("images/icons/" & oNode.getAttribute("icon") & "") & "' style='border: 1px solid gold' />" & oNode.text & "</a><br />"Elseresponse.write ""End IfEnd If'Checks if an if statement is requiredIf RequiredIfStatement = "NONE" OR IsEmpty(RequiredIfStatement) thenresponse.write ""ElseIfStatementCode = "If " & RequiredIfStatement & " then response.write ""<a href=""" & Replace(oNode.getAttribute("destination"),"_","&") & """ class=""link""><img src='" & BaseDirectory("images/icons/" & oNode.getAttribute("icon") & "") & "' style='border: 1px solid gold' />" & oNode.text & "</a><br />"" Else response.write """" End If"response.write IfStatementCodeExecute(IfStatementCode) 'The error comes from this lineEnd IfEnd IfNextloopEnd sub The XML Code is this: <City name="Dragoth" portrait="dragoth.png"><Description>Dragoth is a small town, but well situated for new comers as it has many different facilities for all different professions.</Description><AreaPreCode></AreaPreCode><Links><Link destination="#HEADER#" requirement="NONE">Town Square</Link><Link destination="Content.asp?LocationID=3" icon="market.png" requirement="NONE">Market</Link><Link destination="Content.asp?LocationID=4" icon="inn.png" requirement="NONE">Inn</Link><Link destination="Content.asp?LocationID=5" icon="chest.png" requirement="NONE">Vault</Link><Link destination="Content.asp?LocationID=6" icon="tutorial-icon.png" requirement="Hero.HaveQuestObjective(1,2) = 1">Town Crier</Link><Link destination="Content.asp?LocationID=6" icon="tutorial-icon.png" requirement="Hero.HaveQuestObjective(1,6) = 1 AND Hero.QuestIsComplete(1) = 0">Town Crier</Link><Link destination="#SPACE#"></Link><Link destination="#HEADER#" Event="1">Leave Town</Link><Link destination="Content.asp?LocationID=7_Travel=1" Event="1" icon="gates.png">City Gates (1 Turn)</Link><Link>END OF LINKS</Link></Links></City> Here is the IfStatementCode variable value after being parsed: If Hero.HaveQuestObjective(1,2) = 1 then response.write "<a class=""link"" href=""Content.asp?LocationID=6""><img style=""border: 1px solid gold"" src=""http://localhost/DragonCraft/images/icons/tutorial-icon.png"">Town Crier</a><br>" Else response.write "" End If Link to comment Share on other sites More sharing options...
justsomeguy Posted March 28, 2012 Share Posted March 28, 2012 Which line does it say the error is on? Link to comment Share on other sites More sharing options...
Striped Fish2 Posted March 28, 2012 Author Share Posted March 28, 2012 Execute(IfStatementCode) 'The error comes from this line Link to comment Share on other sites More sharing options...
justsomeguy Posted March 28, 2012 Share Posted March 28, 2012 It sounds like you need to use either colons or embedded line breaks to separate the statements in the code to execute. http://msdn.microsoft.com/en-us/library/03t418d2(VS.85).aspx Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.