Uninitialized class variable
-
I'm trying to make a script remember the values the user puts in during a SketchUp session so that he wont have to re enter them every time the script is run.
When for example using:
module Mymodule class Myclass def initialize #Setting default values @myvariable = 25.mm unless @myvariable #And so on......the script works but wont remember the settings when run again.
When using
@@myvariable = 25.mm unless @@myvariable
I get a "Uninitialized class variable" error message.What am I doing wrong?
-
Should it be
@@myvariable = niland then@myvariablewith just one @ or was that a typo? -
@pixero said:
Should it be
@@myvariable = niland then@myvariablewith just one @ or was that a typo?I just copied your code and added the @@myvariable=nil to it. The typo, @myvariable, was in your original code.
It should be @@myvariable everwhere.
-
@pixero said:
I'm trying to make a script remember the values the user puts in during a SketchUp session so that he wont have to re enter them every time the script is run.
When for example using:
module Mymodule > class Myclass > > def initialize > #Setting default values > @myvariable = 25.mm unless @myvariable > > #And so on......the script works but wont remember the settings when run again.
When using
@@myvariable = 25.mm unless @@myvariable
I get a "Uninitialized class variable" error message.What am I doing wrong?
You just need to make a dummy assignment to it just after class declaration.
module Mymodule class Myclass @@myvariable=nil def initialize #Setting default values @@myvariable = 25.mm unless @myvariable #And so on...... -
Thanks, that worked.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement