|
View:
New views
12 Messages
—
Rating Filter:
Alert me
|
|
|
NB not displaying Ruby Instance Variables while debuggingI cannot see Ruby instance variables (variables preceded by @) while debugging. I see local and global variables. Am I missing something? (I did search but only found 2 posts not related to this exact problem)
for instance, if you debug the following example, I only see the "t" variable. the "@s" variable is not listed. HOWEVER, if I add "@s" to the "watched" variables list, it shows up there. #-----Start here t=Time.now @s=Time.now #put breakpoint immediately below this line puts t puts @s #-----End here thanks!!! |
|
|
Re: NB not displaying Ruby Instance Variables while debuggingOn Fri, Jun 27, 2008 at 2:00 PM, Domenic
<domenic.padula@...> wrote: > for instance, if you debug the following example, I only see the "t" > variable. the "@s" variable is not listed. HOWEVER, if I add "@s" to the > "watched" variables list, it shows up there. There's an entry for 'self' in the variables window - it's under there. -- James Moore | james@... blog.restphone.com --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: NB not displaying Ruby Instance Variables while debuggingI thought it was there as I saw another post in reference to it but I do not have any self variable. I have tested this on 3 computers. Strange. In NB, I'm not using Jruby, I am using Ruby 1.8.4.
|
|
|
Re: NB not displaying Ruby Instance Variables while debuggingHello Dominic,
You realize that you are creating your instance variable in the global name space so there is no easy way to see it in NetBeans unless you go digging through the global variables. Instance variables usually make sense as members of a class and define class state. To see how, set up the following snippet of code in your NetBeans editor: class Test def initialize @s=Time.now end def get_time @s end end t = Test.new puts t.get_time You can put your breakpoint on the last line, i.e., puts t.get_time and run it through debugger. When the program breaks on this line, you should see the variable t under local variable panel. This is an instance of the Test class and if you click on "t" you should see "@s" with the time value. Hope this helps. Bharat |
|
|
Re: NB not displaying Ruby Instance Variables while debuggingThank you! I see "self" now (and the instance variables contained in self).
What was/is confusing me is that I've been using Arachno Ruby-IDE and liked Netbeans and thought I'd convert. In Arachno, you don't need to put the Instance variable in a class to show up. They are just listed with other variables while debugging. Thank you for your help. I am not a programmer but am trying to teach myself scripting and Ruby. I've created a couple of GUI applications using Ruby (vruby) with 2400 lines or so of code and refer to separate script that I have required in my main script. The only way I was able to refer to the variables in the other script was to make them all instance variables. I'm sure this is due to my inexperience. Any thoughts if there is a way for me to customize Netbeans to include Instance variables in the list of local variables while debugging? thanks for your help! Domenic
|
|
|
Re: NB not displaying Ruby Instance Variables while debuggingHello Domenic,
You wrote: "I've created a couple of GUI applications using Ruby (vruby) with 2400 lines or so of code and refer to separate script that I have required in my main script. The only way I was able to refer to the variables in the other script was to make them all instance variables. I'm sure this is due to my inexperience." I have never used Ruby to create a GUI application yet so I am not in a position to advice you on that. One thing that I can comment on is that I have never seen instance variables being used in the manner that you have. The whole purpose of instance variables and method is that they help create instance level state/behavior that are common across all instances belonging to a class. So creating instance variables that are not associated with a particular class is not a very good idea to begin with -- at least in my opinion. The way you have created your application puts the instance variables in the global (main) namespace. You may want to pick-up an introductory Ruby programming book from your local bookstore. I have quite a few of them. Beginning Ruby by Peter Cooper is especially good for beginners. Dave Thomas is upgrading his famous pick-axe book for Ruby 1.9, though it is at a slightly more advanced level than Peter Cooper's book. Kind regards, Bharat |
|
|
Re: NB not displaying Ruby Instance Variables while debuggingBharat,
Thank you for the help. I do have the Pixaxe and reference it often. I've been working on acquiring more books and learning materials. I only used instance variables to reference variables that were in a separate script that was called using "require" at the top of the main script. Is that wrong? I couldn't get it to work any other way. thank you! Domenic
|
|
|
Re: NB not displaying Ruby Instance Variables while debuggingPlease show some examples, then I can be in a better position to comment
|
|
|
Re: NB not displaying Ruby Instance Variables while debuggingIn the below example, I cannot see the @s variable unless I add it as a watched variable.
module Test def get_time @s=Time.now end end include Test t = get_time puts t
|
|
|
Re: NB not displaying Ruby Instance Variables while debuggingSame thing. You have defined a module all-right, but look at where you are including it? It is in the global namespace, therefore, the instance variable goes into the global name space and gets lost in the extensive list of other global namespace members such as environment variables etc. If you define a small TestClass and include the Test module in it, I bet you will have a much easier time finding it.
|
|
|
Re: NB not displaying Ruby Instance Variables while debuggingThanks for all your help. I'll try that.
|
|
|
Re: NB not displaying Ruby Instance Variables while debuggingDomenic wrote:
> I cannot see Ruby instance variables (variables preceded by @) while > debugging. I see local and global variables. Am I missing something? (I did > search but only found 2 posts not related to this exact problem) > > for instance, if you debug the following example, I only see the "t" > variable. the "@s" variable is not listed. HOWEVER, if I add "@s" to the > "watched" variables list, it shows up there. > > #-----Start here > t=Time.now > @s=Time.now > #put breakpoint immediately below this line > puts t > puts @s > #-----End here Hi Domenic, I just add that 'self' is hidden/excluded on purpose in the debugger backend, in listing variables on top level. I do not remember reasons (was done so in the backend long time ago), but likely would be confusing, although in this case it seems contrary. m. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
| Free Forum Powered by Nabble | Forum Help |