我在 Classic ASP 上的 Session 变量遇到了一些问题。在以下代码的第 19 行,我收到“类型不匹配:'i'”错误
- debug.asp 是 session.asp 中包含的一个模块,我的程序中的另一个模块
<% '---------------------------------------------------------------------------- ' File: /include/script/debug.asp ' Author: Vladimir Charkot ' Create Date: 15/05/2013 ' Description: Generate a server debug log on client '---------------------------------------------------------------------------- Redim debugTable(2,0) Sub initDebug(debugLevel) Session("debugEntries") = 0 Session("debugLevel") = "e" Call debugMsg("e","Debug initialized") End Sub Sub debugMsg(lv, str) If IsEmpty(Session("debugEntries")) Then i = 0 Else i = Session("debugEntries") <-- Line 21, Type mismatch error IF CInt() IS APPLIED TO SESSION VARIABLE End If i = i + 1 <-- Line 23, Type mismatch error Redim Preserve debugTable(2,i) debugTable(0,i-1) = lv debugTable(1,i-1) = str Session("debugEntries") = CInt(i) End Sub Function debugToClient() Dim list Dim func list = jsDebugList() func = jsDebugFunction(list) debugToClient = func End Function Function jsDebugList() Dim i Dim list If IsEmpty(Session("debugEntries")) Then i = 0 Else i = Session("debugEntries") End If list = "[" for n = 0 to i - 2 'Add the last one outside the loop list = list & "{debugLevel : """ & debugTable(0,n) & """, message : """ & debugTable(1,n) & """}, " ' i.e.: {debugLevel : "e", message : "Error on application"}, next list = list & "{debugLevel : """ & debugTable(0,n) & """, message : """ & debugTable(1,n) & """}" list = list & "]" jsDebugList = list End Function Function jsDebugFunction(l) Dim f f = "function debug(){" f = f & " debugList = " & l & ";" f = f & " for (elem in debugList){" f = f & " console.log(elem.debugLevel + "": "" + elem.message);" f = f & " }" f = f & "}" jsDebugFunction = f End Function %>
- 这里是session.asp相关代码,其中调用了debug subs和functions
<!-- #include virtual="/gu/include/script/debug.asp" --> sub InitSession() (...stuff...) Call initDebug("e") end sub sub CheckSession() ' If not a new session, this code has already been executed. if stuff then timeout() end if Call debugMsg("e", "CheckSession() Executed") end sub
- 最后, session.asp 包含在我的页面文件中,我在浏览器上调用 open 并返回类型不匹配错误。
希望你能帮助我,我真的认为我已经尝试了一切。除了巫毒,黑魔法和那种。谢谢!