[Gambas-user] Doing keyword operations/lookups
Benoît Minisini
g4mba5 at gmail.com
Sun Jan 24 18:30:49 CET 2021
Le 24/01/2021 à 14:52, Brian G a écrit :
> I have attached a script which compares two methods of handling keyword
> processing in a program. That is looking up the symbol followed by doing
> processing as required.
>
> Method one used a collection, and key word index lookup the value being
> an integer index, followed by an
> On key Goto xxx,xxx,xxx,...
>
> Method two uses select and case for the keys
>
> The first method it two to three times faster than the second especially
> when using fast.
> Would the first method be considered usable, or is there a better way to
> gain the performance.
>
> Anyone have any ideas?
> It sure looks ugly!
>
>
> Thank You
> Brian G
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
It's logical, and the SELECT will test each CASE until it finds a
matching, whereas the first method using a collection is an hash
followed by a direct access.
Otherwise, I plan to add a Key property that returns the pressed key as
a string with key and shortcut (For example "CTRL+A"). This string can
then be tested directly or used as a key inside a collection.
It will make the code more readable than testing Key modifiers property
and Key codes.
Regards,
--
Benoît Minisini
More information about the User
mailing list