Help me out here people

| | Comments (13)

So I've heard lots about this "immediate window" thing from VB land, but I must admit that I don't know very much about it or when it's used. My understanding is that it's basically a place for you to input expressions which are then evaluated and displayed. So if I put 2+2, it would show me 4. Is that about it?

Basically, can someone give me the quick and dirty information about what an immediate window does and why one uses it, as well as some real life examples?

13 Comments

Maybe this helps?
http://www.samspublishing.com/library/content.asp?b=STY_VB6_24hours&seqNum=207&rl=1

I hope you and Lis have a good, healthy and joyable new year.

Would be real cool to have this in real basic

I rarely used it except when I wanted to look at the value of a variable that was not in one of my watches

Then it became handy to know what the current value of some global variable was

The other thing you used it for was setting the value of a variable as you could also do

x = 6

and this would change the value of X from then on

RB's debugger & variable browser already has at least as much functionality as the immediate window for looking at the value of variables but lost it's ability to change the values while debugging

If you're taking a poll: I never used it. Then again, I'm not a power user. I like RB's debugger a lot (when it works). As Norman noted changing values would be cool but you don't necessarily need to implement an immediate window to accomplish that.

~joe

We use it in VB all the time. But what we're using it for is mainly console type output.

If it were up to me, I'd say DON'T implement the immediate window in RB since most of its functionality is there. In different places and ways but possible now.

However, I'd really love to have the tooltip variable value that VB6 has. When debugging and going line by line you can hover the mouse pointer over any variable and a tooltip shows the value. It's quick and its dirty and lets me look at the variables value whenever I want.

The above responses indicate that the immediate window is probably the most unused power feature in VB. The immediate window acts like a console output (Debug.Print output is directed to the window) in its most basic sense.
The immediate window also allows you to execute straight VB code in the current location... So you could type.. X = 6 to be executed immediately making the value of X change. You could also type :

For I = 1 to 10: msgbox str(i) : next
in order to bubble up 10 message boxes.

In order to view the value of a variable you should generally use the watch window but the immediate window gives you the option to do a debug.print mainwindow.caption

The immediate window can also access the entire vb application, essentially as if the code was executed in place at the current break location. so you can even call MainWindow.Show

It is definitely one of the most powerful tools for debugging. Its like having a script compiler in place at the break location.

Out of all the stuff you can do with the immediate window being able to alter variables in an app being debugged is the one thing I'd really use and that I miss from 5.5

Beyond that I've used some of the other items mentioned but not nearly as much as I've used it to alter a value

I forgot about the stuff that talk2sk talked about. We use quite a few 'debug' routines that take an object and show it to us using debug.print statements. In the immediate window we'd type: debug_displaydictionary d
It would then call the debug_displaydictionary method with the passed in dictionary object and display it in the immediate window.

Again, it's not like you can't do that by other ways and means, but it's very fast and easy to use and can be used at any time at the whim of the user.

Bob Keeney Says:
" ...However, I’d really love to have the tooltip variable value that VB6 has. When debugging and going line by line you can hover the mouse pointer over any variable and a tooltip shows the value. It’s quick and its dirty and lets me look at the variables value whenever I want."


I used the same feature in and its what i miss most about 4D. I am glad to see someone at realbasic is paying attention to the debugger. I hope to see this feature added at some point, and may other cool things that I don't even know yet that I am missing.

The immediate window in VB is extremely useful. I use it all the time and would love to see it in RB. I write a lot of small one-off applications to parse data files and such and I commonly use debug.print to see results quickly without even having to write to a file.

Another thing that I do all the time is test subs and functions. After I write a small helper function, I can go to the immediate window and type something like "A = MyFunction("Test Value")". Then type "Print A". The value of A is printed (like debug.print) to the immediate window. This is very nice since you can test this single function without running the whole app.

Hmm... so it sounds like the immediate window serves three main purposes:

1) A console for debugging statements to be logged to

2) Querying and modifying property values

3) An interpreter for running code

Sounds about right?

Per Aaron's conclusions above, here's my own idiosyncratic opinion:

1) On the Mac, we have a console (so does Linux, and I assume Windows still has one), so adding a console directly to the RB IDE isn't critical.

2) Querying and modifying property values while debugging is always a nice feature. I like the tooltip idea mentioned by Bob if it could be done in the source code panel while debugging. If control-clicking the variable in the source code panel would then allow you to change the property value, even better.

3) I thought that one reason RS moved away from interpreting code was due to subtle differences in behavior between interpreteed and compiled apps. Wouldn't this reintroduce the problem?

Well, I don't know if my conclusions are correct or not. ;-) As for #1, I can see that as being useful to have in the IDE. For instance, when remote debugging, it may be nearly impossible to get the information back if you're remote debugging to a customer's machine and they're not tech-savvy. #2 is definitely a good one, but I don't see that as being too needed in a separate UI. The debugger's variables viewer can work for that (perhaps in conjunction with some sort of easy-to-use searching capabilities). Though I do like the tooltip feature myself, and can see that as being useful.

#3 is a point which I may or may not get.

Leave a comment

Disclaimer

I'm currently an employee of REAL Software. My blog is mine. The opinions represented in this blog are mine as well and may not represent my employer's opinions. All original material is copyrighted and property of the author.

REALbasic® is a registered trademark of REAL Software, Inc. REAL SQL Server™ and Lingua™ are pending trademarks of REAL Software, Inc. All rights reserved.