PoolConstantsDictionary

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

PoolConstantsDictionary

Jochen Riekhof
Hi...

today I wanted to create a PoolConstantsDictionary with a set of constants
manually for the first time.
To my surprise I could not find any Menu items supporting this. So, how can
I create an register a PoolConstantsDictionary
with a set of constants and make it belong it to my package in the correct
way?

I found out that I can just type the name into a class definition, and
afterwards it is created (after a somewhat strange message box saying
something like "do you want to create one?" [Abort][Retry][Ignore] - not
exactly the button labels i expected ;-).

But it seems that cannot add any constants afterwards in the
PoolDictionaries View (probably because it is constant?).

Ciao

...Jochen


Reply | Threaded
Open this post in threaded view
|

Re: PoolConstantsDictionary

Ian Bartholomew-18
Jochen,

> today I wanted to create a PoolConstantsDictionary with a set of
> constants manually for the first time.

I think that the easiest way is just to use a workspace.  Evaluate ...

Smalltalk at: 'TestPool' put: PoolConstantsDictionary new.

and add/edit/delete items using something like ....

(Smalltalk at: 'TestPool')
    at: 'const1' put: 1;
    at: 'const2' put: 2

or you can, obviously, combine the two operations.

Smalltalk at: 'TestPool' put: (PoolConstantsDictionary new.
    at: 'const1' put: 1;
    at: 'const2' put: 2;
    yourself)

Once you have created a global then you can add it to a package using
the Globals/Add uncommitted option in the PackageBrowser.

> But it seems that cannot add any constants afterwards in the
> PoolDictionaries View (probably because it is constant?).

You should be able to?.  nb The key can be a String (and needs the
single quotes when input into the dialog) or a Symbol but the value
field can evaluate to any object.  Remember that the text you type into
the dialog is evaluated so you can also enter an expression like - 'a' ,
'b' , 1 printString - into the key field and end up with a key of 'ab'1.

--
Ian

Use the Reply-To address to contact me.
Mail sent to the From address is ignored.


Reply | Threaded
Open this post in threaded view
|

Re: PoolConstantsDictionary

Jochen Riekhof
Ian...

> Once you have created a global then you can add it to a package using
> the Globals/Add uncommitted option in the PackageBrowser.

Oops, it seems I just forgot that PoolDictionaries are simply globels :-).
Thanks for the refresh!
(Probably I should read a bit in my good old "Smalltalk80 -The language"
book again).

Editing in the PoolDictionary window works, but you can only specify strings
as keys, otherwise a walkback occurs (ListView cannot find association...)..

By elaborating on this I noticed that "Pool Dictionaries" as well as "User
preferences" are nowhere accessible through the menu (or maybe I did not
find it?). Wouldn't it be nice to have them there? I always resize my
Dolphin main window to show only menu and toolbar, so I have to enlarge it
to get to these two items.

Ciao

...Jochen


Reply | Threaded
Open this post in threaded view
|

Re: PoolConstantsDictionary

Ian Bartholomew-18
Jochen,

> Editing in the PoolDictionary window works, but you can only specify
> strings as keys, otherwise a walkback occurs (ListView cannot find
> association...)..

So it does - I don't often add keys that way so I can't remember
noticing this behaviour.  The Symbol is converted to a String before the
key/value pair is added to the PCD (which works) but the ListView then
searches for the original Symbol - which bombs.  Other than creating a
new type of Inspector for PCDs I can't see any obvious way round this so
it's probably best to just treat it as something you shouldn't do :-)

> By elaborating on this I noticed that "Pool Dictionaries" as well as
> "User preferences" are nowhere accessible through the menu (or maybe
> I did not find it?).

You're right about Pool Dictionaries but User Preferences are available
through Tools/Options/Inspect.  This option is also present in each
individual browser but then displays the preferences for that particular
tool.

If your interested I've just found a simple, single method change, that
adds "Pool Dictionaries" to the Tools menu.  Let me know and I'll mail
it to you.

--
Ian

Use the Reply-To address to contact me.
Mail sent to the From address is ignored.


Reply | Threaded
Open this post in threaded view
|

Re: PoolConstantsDictionary

Jochen Riekhof
> If your interested I've just found a simple, single method change, that
> adds "Pool Dictionaries" to the Tools menu.  Let me know and I'll mail
> it to you.

Thanks, that would be great!

[hidden email]

Ciao

...Jochen