I'm still struggling through some basics here.. Please tell me where I have something wrong.
For most purposes, it seems that I can treat "Class.var" and "var" as interchangeable, once "Class.var" has been assigned a value.
To avoid possible conflicts between instance variables and base-class static variables of the same name, I have adopted the habit of always using "base.var" and "this.var" instead of just "var" even where "var" would work. I use unqualified names for function-local variables that are not intended to be shared among methods.
I tried calling a DLL with an argument &base.var, expecting it to change the "var" declared as static in base.
It did not change base.var.
So I used &localvar, and after the call did base.var := localvar. That fixed the problem, but it feels a bit awkward.
Is there a syntax for properly taking the address of base.var?
Or did I mis-interpret my results?
Any clarifications would be appreciated.
&Class.var ?
Re: &Class.var ?
Thanks. That looks as though it may work... but just to check..jethrow wrote:Try the GetAddress method
Should I use
Code: Select all
Class.GetAddress(var)
Re: &Class.var ?
Class.var is an expression. Anywhere that you can use an expression to compute a value, you can use Class.var. Class.var returns a value, not a variable reference. If it returned "value", for instance, &Class.var would be equivalent to &"value".For most purposes, it seems that I can treat "Class.var" and "var" as interchangeable
Don't do literally that; use the class name. You can use base.var in a method to refer to a property in the base class (not the current class or the object's base), but base.var := x will not work unless var is implemented by a property setter or meta-function. It works for reading static variables too, but if you make using it a habit, you're more likely to confuse yourself when you need to assign a value.I have adopted the habit of always using "base.var"
Only if var contains the name of the field.Class.GetAddress(var)
Re: &Class.var ?
Again, thank you Lexikos
I am still fuzzy about base... I suppose understanding will come with time.
You say "Only if var contains the name of the field". Hmm. Ok. Does that mean that I should instead code:That makes sense, assuming it is true.
Another question. How are you getting those neat in-line boxes that you use where I would say "base.var"? I was not familiar with any of this stuff just a few weeks ago, I'm happy just to have figured out how to put in a code box, but there is a lot more to learn.
In fact I have been using Class.var, not literally "base.var".Don't do literally that;...
I am still fuzzy about base... I suppose understanding will come with time.
You say "Only if var contains the name of the field". Hmm. Ok. Does that mean that I should instead code:
Code: Select all
Class.GetAddr("var"]
Another question. How are you getting those neat in-line boxes that you use where I would say "base.var"? I was not familiar with any of this stuff just a few weeks ago, I'm happy just to have figured out how to put in a code box, but there is a lot more to learn.
Re: &Class.var ?
Just add quotes if it's meant literally: xx.var -> xx.GetAddress("var") or xx[yy] -> xx.GetAddress(yy) (yy is a variable containing a key).
For the inline code, I just type [ c ] the code [ / c ] without spaces. There's also a "c" button in the full post editor.
If you want to know how to duplicate formatting that you see in someone's post, you can view the "source code" of the post by quoting it.
For the inline code, I just type [ c ] the code [ / c ] without spaces. There's also a "c" button in the full post editor.
If you want to know how to duplicate formatting that you see in someone's post, you can view the "source code" of the post by quoting it.
Who is online
Users browsing this forum: No registered users and 218 guests