create share dictionary

Hi eveyone
obviously i’v didn’t understand very well OOP
I need to create dictionary that can be read/write by other method
It work only with dim d As new dictionary inside a method
Won’t work when i create dictionary in property… with no New before
thanks

Create a property called mDict, and set it to be of type Dictionary.
Create computed property called Dict, and set it to be of type Dictionary.
Implement the Get part of the computed property:

If mDict Is Nil Then mDict = New Dictionary() End Return mDict
Now you can use Dict in different methods.

Thanks Eli
It work… of course you knew :slight_smile:
but can you tell me why it’s so complicate
( not very… but more than create a integer in property )
thanks

It’s not really all that complicated. Integers, Doubles, Colors, Currency, Strings and a handful of others are native datatypes that only need to be declared with the dim statement.

dim i as integer

The dictionary is a class that has to be instantiated with the new command. There are MANY examples of this in Xojo. There are too many classes to list.

dim d as dictionary
d = new dictionary

Or combined into one line

dim d as new dictionary

This is where using the Xojo Language Reference can be helpful (Look in the help menu). It will have examples of how to use everything.

If you’re looking for more training, we have 65 hours of video for subscribers over at http://xojo.bkeeney.com/XojoTraining/. That’s over 200 videos with most of them coming with a project file containing source you can use in your own project. We have 3 start to finish projects (2 desktop and 1 web)

Thank you both