У меня возникли проблемы с переменной Session на классическом ASP. В строке 19 следующего кода, я получаю «Несоответствие типа:„я“» ошибкаКлассическое несоответствие типа ASP
- 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 соответствующий код, где отладки подлодки и функции называются
<!-- #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 включен на моей странице файл, тот, который я называю открытым на моем браузере, и возвращает ошибку несоответствия типов.
Надеюсь, вы можете мне помочь, я действительно думаю, что я уже все пробовал. Кроме Вуду, черной магии и тому подобного. Спасибо!
Какое значение для сессии («debugEntries») в строке 17? Можете ли вы выполнить Response.Write и проверить значение до вызова строки 18? – Csharp
Я попробую. В первый раз это будет 0, но я проверю. Отличное предложение. – Vladimir