I'm building a treeview page that is generated and expanded as the user
opens links from it, and am using an array stored in a session variable
to maintain the tree.
The problem I've hit is that of how to corectly dim the array variable.
the variables are dimed after option explicit, but
having
dim arrtree
there throws a type mismatch at line 116 when the array is empty
but not when its populated
having
dim arrtree()
throws same at line 87 when the array is populated, but is fine when its
empty
obviously trying to have two dim statements in the if-else throws a
'redefined' error.
other than removing the option line, how to get round this?
this is the part of the code that is doing the work:
if intmenuid > 0 then
if session("arrtreeflag") > "" then
arrtree = session("arrtree")'########line 87
thisid = Request.QueryString("thisid")
x = ubound(arrtree,2)+1
arrtree(9,thisid) = 1
sql = "select tagid,rtrim(m1.menuname) from navigate_tags t
left join navigate_menus m1 on tagid = m1.menuid where
parentid = "&intmenuid&" and menuname is not null order by
node"
else
sql = "select tagid,rtrim(menuname) from navigate_tags,
navigate_menus where parentid = 0 and node = 0 and tagid =
menuid"
x = 0
level = 0
parentnode = 0
strmessage = "reset"
end if
else
sql = "select tagid,rtrim(menuname) from navigate_tags,
navigate_menus where parentid = 0 and node = 0 and tagid = menuid"
x = 0
level = 0
parentnode = 0
intmenuid = 0
end if
if strmessage > "" then Response.Write "timeout - tree reset to top<br/>"
'sql = "cn_viewtree_count "&intmenuid&" "
Response.Write "<!-- sql["&sql&"] -->"
set rs = conn.execute(sql)
if not rs.eof then
do while not rs.eof
Response.Write "<!-- x["&x&"] -->"
redim preserve arrtree(10,x) ''''##########line 116
arrtree(0,x) = rs(0) ' node id
arrtree(1,x) = 0 ' 0 = menu 1 = item
if intmenuid > 0 then arrtree(2,x) = intmenuid ' parentid
if intmenuid = 0 then arrtree(2,x) = 0 ' parentid
arrtree(3,x) = rs(1) ' name
Response.Write "<!-- sql[cn_viewtree_child "&rs(0)&" ] -->"
set rs_c = conn.execute("cn_viewtree_child "&rs(0)&" ")
arrtree(4,x) = rs_c(0) ' has child 0 false 1 true
arrtree(5,x) = 0 ' has been used in tree
arrtree(6,x) = level ' tree level
arrtree(7,x) = x ' array node
arrtree(8,x) = intmenuid'parentnode 'parent array node
arrtree(9,x) = 0 ' has been opened
Response.Write "adding index["&x&"] id["&arrtree(0,x)&"]par
["&arrtree(2,x)&"]name["&arrtree(3,x)&"]child["&arrtree(4,x)&"]level
["&arrtree(6,x)&"]parentnode["&arrtree(8,x)&"] <br />"
x=x+ 1
rs.movenext
loop
end if
'arrtree(4,x) = 0 ' has child 0 false 1 true
set session("arrtree") = nothing
session("arrtree") = arrtree
set session("arrtreeflag") = nothing
session("arrtreeflag") = "current"