From: | Jim Peters |
Date: | 21 Sep 2000 at 10:11:35 |
Subject: | Re: AMIOPEN: Hotkey Config/Need suggestions |
On Thu, Sep 21, 2000 at 09:55:42AM +0200, Aaron Optimizer Digulla wrote:
> > I may have come up with a different solution though that uses checksums in
> > the config file so the amount of memory used stays the same and lines can be in
> > any order, plus have any sort of descriptor. I'm testing it now.
>
> *Argh* Use hashes, man ! That's what they are for !! Check the Ami docs for
> hash and atoms.
>
> To explain: An atom maps a string to an integer. And a hash is a dictionary
> where you can efficiently store values under keys and look them up later with
> these keys. The code will look like this:
>
> - Create a hash
> - Register all config strings as atoms
> - Use the IDs of the atoms to put the default values in the hash
> - Read the config. Lookup the ids of the items and put them into
> the hash.
> - Later in the code, query the hash for the config items by using
> the ids.
YES, YES, YES. This is what I meant. Perhaps it was a bad idea to
present this 3-digit-numbers-as-label idea - it was just to show that
you could even use old-fashioned non-extensible programming practices
with a new flexible approach, for those who really want to save those
bytes. Forget I mentioned it.
Concrete example of what I meant:
ExecMacro = Alt-X # Execute macro
OtherFunc = Alt-O # Perform other function
Sleep = Alt-Z # Go to sleep
ShowStatus = Alt-S # Show status bar
Jim
P.S. I'm holding off buying the SDK for the moment whilst I try and
focus on a few other things, so I don't yet know the implementation
details of hashes under Ami. I'll trust the `optimizer' on this ...