• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 345
  • Last Modified:

Print_r functionality

I'm trying to get this to work, but I cannot seem to see how the Request.Form object is created ... i thought it would just a scripting.dictionary, but it seems more advanced(or stupid) than that ...

<%
Sub Print_r(itm,tabs)
    Dim echItm, i, stabs
    For i = 1 to tabs
        stabs = stabs & vbTab
    Next
    If IsArray(itm) Then
        Response.Write stabs & "Array(" & vbCrLf
        stabs = stabs & vbTab
        For i=LBound(itm) to UBound(itm)
            Response.Write stabs & i & "="
            Call Print_r(itm(i),tabs+1)
        Next
        Response.Write stabs & ")" & vbCrLf
    ElseIf IsObject(itm) Then
        Response.Write stabs & "Object(" & vbCrLf
        stabs = stabs & vbTab
        For each echItm in itm
            Response.Write stabs & """" & echItm & """="
            Call Print_r(itm.Item(echItm),tabs+1)
        Next
        Response.Write stabs & ")" & vbCrLf
    ElseIf IsNumeric(itm) Then
        Response.Write itm & vbCrLf
    Else
        Response.Write """" & itm & """" & vbCrLf
    End If
End Sub
Call Print_r(Request.Form,0)
Call Print_r(Session.Contents,0)

%>
<form action="test.asp" method=post>
<input type="hidden" name="test51" value="236" />
<input type="hidden" name="test11" value="253" />
<input type="hidden" name="test31" value="231" />
<input type="hidden" name="test1" value="223" />
<input type="hidden" name="test15" value="33" />
<input type="hidden" name="test41" value="253" />
<input type="submit" name="sub" value="Mit" />
</form>

Please note the Session.Contents part works perfectly fine, but can anyone see what this would give me the error ...
Request object error 'ASP 0105 : 80004005'

Index out of range

/test.asp, line 20

An array index is out of range.

Thank you.
0
ThaSmartUno
Asked:
ThaSmartUno
  • 3
  • 2
1 Solution
 
ThaSmartUnoAuthor Commented:
For Instance ... taking that same sub routine ...
If Not IsObject(Session("items")) Then
    Set Session("items") = Server.CreateObject("Scripting.Dictionary")
    Session("items").Add "test", "testval"
    Session("items").Add "test5", "testval153"
    Session("items").Add "test12", "testval142"
    Session("items").Add "test66", "testval12"
End If

adding that to the page.
And commenting the line Call Print_r(Request.Form,0)
It works as expected... so I guess my real question is ... what format is Request.Form ... how is it saved
0
 
nurbekCommented:
try with disabling the calling recursion function
because it is already looping (For Each)

   ElseIf IsObject(itm) Then
        Response.Write stabs & "Object(" & vbCrLf
        stabs = stabs & vbTab
        For each echItm in itm
            Response.Write stabs & """" & echItm & """="
            'Call Print_r(itm.Item(echItm),tabs+1)
        Next
        Response.Write stabs & ")" & vbCrLf
0
 
ThaSmartUnoAuthor Commented:
yes that works ... but as you can see if you have an object, with another object inside it does not go through the variables inside the first object

thats what the recursion is for
0
 
nurbekCommented:
check here about how to list the items in the objects

http://www.4guysfromrolla.com/webtech/021099-1.shtml

i think you need to write another If or function for form elements

0
 
ThaSmartUnoAuthor Commented:
Well it seems like thats the only way to do it.  Thanks for the help.
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now