?
Solved

Print_r functionality

Posted on 2005-02-28
5
Medium Priority
?
344 Views
Last Modified: 2012-06-27
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
Comment
Question by:ThaSmartUno
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 10

Author Comment

by:ThaSmartUno
ID: 13423029
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
 
LVL 13

Expert Comment

by:nurbek
ID: 13423049
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
 
LVL 10

Author Comment

by:ThaSmartUno
ID: 13423071
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
 
LVL 13

Accepted Solution

by:
nurbek earned 2000 total points
ID: 13423162
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
 
LVL 10

Author Comment

by:ThaSmartUno
ID: 13424949
Well it seems like thats the only way to do it.  Thanks for the help.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question