April 25, 2024, 03:06:34 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


constants and class members questions

Started by Guilect, October 28, 2008, 05:20:55 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Guilect

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

LarryMc

October 28, 2008, 06:08:42 AM #1 Last Edit: October 28, 2008, 06:10:39 AM by Larry McCaughn
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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Guilect

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.

Ionic Wind Support Team

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.
Ionic Wind Support Team