Re: Best way to inspect the contents of a big variable?

Unknown <[email protected]>
Newsgroups gmane.comp.mozilla.devel.jsdebugger
Organization Another Netscape Collabra Server User
Message-ID <[email protected]>
The best way to view something that large would probably be to dump the 
value to a file and look at it in an editor.  To do that, you'll need to 
do a few /evald commands, which execute script in the context of Venkman 
itself.

First, get the variable you want into a $[n] variable, by evaling it 
while stopped...
/eval document.getElementById("apis").innerHTML
 > $[0] = [string] 73078 characters

(you don't actually need the /eval there, since it's the default command)

Then, use a few /evalds to create a file and spew your data...
/evald myfile = fopen("/home/rginda/foo.html", ">");
/evald myfile.write($[0].stringValue);
/evald myfile.close();

It wouldn't be very hard to wrap this functionality in a plugin (or, at 
patch to venkman itself), to add a ``/save-expr <file-name> 
<expression>'' command.

If you really wanted to dump the contents of that variable to the 
Interactive Session window, you could just increase the maxStringLength 
preference with the /pref command.  It's 4000 by default.  To change it 
to 75000, you'd type /pref maxStringLength 75000.  I don't know how long 
it'll take to render that many characters in the Interactive Session 
view though, so I wouldn't recommend it.


Rob.


Paul Rempel wrote:
> Hi,
> I'm using Venkman and find it incredibly useful.  But i'm not sure how to
> "see" what is inside of certain variables that contain a lot of data.
> 
> For example, my web page uses javascript to pupulate a <div> tag.  I can't
> see whats in it by using View-->Source since it only exists in memory.
> 
> I put a breakpoint in my .js file using Venkman, and then in the debugger
> console, I type:
> 
> document.getElementById("apis").innerHTML
> 
> but it doesn't show me the contents, it only says:
> 
>  $[0] = [string] 73078 characters
> 
> What if i want to see what those 73078 characters actually are????  Adding
> it as a watch produces the same problem.
> 
> 
> I tried sending it to an alert() dialog box, but it doesn't all fit and you
> can't copy and paste from those dialog boxes either.
> 
> 
> Any ideas???
> 
> Thanks in advance,
> Paul
> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.