Much of the functionality for the main work website was implemented by someone who has now left. To make life easier, various bits and pieces are generated from an XML file. I've just been doing maintenance on this, because it wouldn't work in a new configuration for some reason, even though it was exactly what it was planned for.
It's an XML tree structure. Sometimes, we want to skip a node, but still operate on its children - so we have a parameter set to "skip".
Can we spot the deliberate mistake, boys and girls?
for intNodeNum = 0 to (objMenuNodeList.length - 1)
set objMenuNode = objMenuNodeList.item(intNodeNum)
next
'---------------------------------------------------------------
'Topmenu="skip" means don't show this node but check whether to
'show its children
'---------------------------------------------------------------
if lcase(objMenuNode.getAttribute("topmenu")) = "skip" then
if objMenuNode.selectNodes("siteMapNode").length > 0 then
rfnWriteTopMenu objMenuNode, strHTML, intTabIndex, false
end if
end if
If you said that the loop at the start sets the objMenuNode item to the last element in the list and then only checks the skip on the last element - meaning that this code will only work as intended for levels that only have one element - you are wrong.
The real bug is that it's written in VBScript, and I don't know it.