IonicWind Software

IWBasic => Object Oriented Programming => Topic started by: Guilect on October 28, 2008, 05:20:55 AM

Title: constants and class members questions
Post by: Guilect on October 28, 2008, 05:20:55 AM
Hi gang,

seems like I should be able to do the following, but it generates an error.
I have tried making the member private but that did not help.
Changing either the const 'variable' name or the member name to non-matching names works OK.
Would appreciate any help.
Thanks in advance.
Const problem = 0


Class foobar
'private
def problem as INT

end CLASS

def test as foobar

test.problem = 999

generates : "undefined variable - problem" at the line test.problem = 999
Title: Re: constants and class members questions
Post by: LarryMc on October 28, 2008, 06:08:42 AM
Get rid of Const problem = 0
If you were trying to initialize problem it should be done in the class construct and shouldn't be a constant.
Larry
Title: Re: constants and class members questions
Post by: Guilect on October 28, 2008, 09:06:01 AM
Larry,
thanks for the quick reply but, no.
It is not meant to be an initialization of a class member.
That would be done inside the class.
This constant is global to the rest of the program.

The question is why can't we have a global constant and a class member of the same name.
Title: Re: constants and class members questions
Post by: Ionic Wind Support Team on October 28, 2008, 09:09:34 AM
You can, in version 1.66, which I will be releasing soon.  This is the bug reported by Sapero here:

http://www.ionicwind.com/forums/index.php/topic,2830.0.html

Classes and types (structures) use the same mechanism for defining variables.