Hello Doug L,

You are correct in that we allow the Dictionary object to run in our (Window-Eyes) process which makes it much faster than when we ran it out of process. Almost a 50 percent increase in speed in some cases. However, Chip's point was even with that the overhead a dictionary object has to deal with is greater than a simple array index. But for what Bruce is using it for there really is no way you could notice a difference using one over the other. So in Bruce's case I have no personal issue with him using a dictionary object over an array. But if there was a much bigger chunk of data to deal with and an array could be used just as easily as a dictionary object than an array would be noticeably faster.

In my mind this whole thing got blown out of proportion with Aaron's personal feelings about a dictionary object and its speed <smile>. I say we all start going through Aaron's code and start nit-picking <smile>.

Doug G

On 6/3/2011 12:02 PM, Doug Lee wrote:
Belated reply to this:  Your assertion that the Scripting.Dictionary
object is slow surprises me, because I thought GW somehow absorbed
that into the Window-Eyes process in a recent update, so it won't
require interprocess communication, marshalling, etc.  Am I dreaming
again?

On Sat, May 28, 2011 at 10:52:56PM -0400, Chip Orange wrote:
    Hi Bruce,



    the choices for how your app works is fine, and always has good and bad
    points of any design.



    For the sake of others though, I want to say there is no language, no
    situation, where the use of a scripting.dictionary object is hundreds,
    if not thousands of times, slower than the use of an array.



    most of the time it makes no noticeable difference to us; but I wrote
    an app here where it was starting to make a difference, and I left it
    as a dictionary object because the rewrite looked to be a lot of
    trouble.  it was incredibly slower than I had predicted when I designed
    the app.



    thanks.



    Chip


      __________________________________________________________________

    From: BT [mailto:[email protected]]
    Sent: Saturday, May 28, 2011 7:43 PM
    To: [email protected]
    Subject: Re: Menu Items and Menu Group?



    Hi Chip,



        Yes and no, but as you say, depending on how many. some languages
    will fight saying the opposite, but that is not why I did what I did. I
    certainly not going to have a million options in my menu.



        For what I did allows me to flip code in a few lines instead of
    lengthy if then else statements. As I said, that was the reason for it.
    Now, having said that I could have done what I am doing with most
    stuff, and that is to use the ID name as the file name whether in the
    ini or variable and such. That could also do some of the same stuff as
    I did in those 2 functions.



        At the moment, the menu items all get unchecked, then the one I am
    focused on gets checked, all as one simple assignment instead of a long
    list of ElseIf statements...

        Also, any numeric values or text, also get passed from that ID or
    to that ID. doing both with just 2 functions.



        I like what it does and until I get into lengthy menu's I will stay
    with what I got.

    NOTE:

        When I did have a long list I used a combo box. That is for
    selecting hour and minute times without using an edit field which
    requires extra checks to validate data, the reason why I went to a
    combo box.

        To make the combo box I use a for statement depending on 12 or 24
    hour format and the minute requires nothing but the 0 to 59 numbers.



        so, in that case no array, just a combo box made on the fly and
    destroyed when leaving the timeDialog.



        So, still doing things a little at a time and testing each stage,
    with changes, deletions, when I find something shorter to use. Keeping
    code down to a minimum and more readable hopefully.



        time to either mow the lawn or walk the dog or both.



            Bruce







    Sent: Saturday, May 28, 2011 4:48 PM

    Subject: RE: Menu Items and Menu Group?

    Hi Bruce,



    I'm not trying to get you to change how you are doing things; this
    doesn't matter on the scale you're working with, but I thought I should
    mention that arrays are much much faster than using a dictionary.



    with an array only a memory address needs to be calculated, and it's a
    simple calculation based on the index number used (ok, with an
    interpreter and these types of arrays it's a little more than that),
    but each interaction with a dictionary entry requires a complete COM
    transaction, with relatively *huge* amounts of overhead.



    we're talking fractions of a second no matter which you use, given a
    collection of a dozen or so items instead of half a million.  but move
    up to half a million, and  you'll become a believer in arrays.





    good luck,



    Chip


      __________________________________________________________________

    From: BT [mailto:[email protected]]
    Sent: Friday, May 27, 2011 4:24 PM
    To: [email protected]
    Subject: Re: Menu Items and Menu Group?



    Hi Aaron,



        Yes, an array does offer one choice, but in my dictionaries, I have
    2 choices. Use of the ID for selection, and any value passed in from
    the IniFile.

        But, dictionaries are also faster, but I am not using it for that
    reason, nor even thought about it.



        For, my second function I wanted to get the item value out that
    would be the value for that item if selected. so an assignment would
    take place using the dictionary, along with using the dictionary as the
    selection nullify and getting/putting...



        Granted as an after thought, Arrays can be set up with index's that
    are not sequential, but could not remember if that was possible in VB,
    but like you say, "Different strokes for different folks."



        At the moment I could not find any good substitute in VB
    commands...



            Bruce



    Sent: Friday, May 27, 2011 4:11 PM

    Subject: Re: Menu Items and Menu Group?

      See see. I would have used an array, and a single routine with an
      on/off parameters, but different strokes for different folks.
      Aaron
      On 5/27/2011 4:07 PM, BT wrote:



    Hi Aaron,



        Just got back from a quick hour break to Ithaca. I did this for one
    reason, to make a universal item function for all items and to reduce
    space.



        Yes, I could make lots of lists, lots of checks, and I reduced a
    lot of if then's to functions, in fact 2 functions...



        so, yes, there is a dictionary, and a list in the case statements,
    but the rest is reduced to 2 function calls.



        I hope that makes it easier for you to understand. You will have to
    wait until I release the app...



            Bruce



    Sent: Friday, May 27, 2011 1:54 PM

    Subject: Re: Menu Items and Menu Group?

      Why would you go through the trouble of creating a dictionary of all
      your menu ids, when you already know what they are based on your
      XML?
      Aaron
      On 5/27/2011 1:41 PM, BT wrote:



    Hi Doug,



        After asking the question I discovered that knowing all the menu
    items and such creates a problem if different types, but a dictionary
    of the only ID's you want does prevent that problem.



        So, below is how I got around the issues. the first function
    unchecks all items inside the dictionary and returns a true to set the
    actual menu item that had been selected, so it gets set true.



        Then the second function uses the dictionary to find the ID on the
    item list to find the value of that item and return the actual menu ID
    of that particular value.



        So this allows me to uncheck a selection and find the ID of a value
    corresponding to that ID...



        So, if choices then one value selects only one item and such...



        You will understand it after I post the cuckoo Clock.



        Just going one step at a time, filling in the menu items,
    selections, and the IniFile with those selections, and the reverse.



            Bruce

    Function SelectMenuItem( menuDict)
     ' Uncheck all menu items and set selected one by passing back true.
     Dim mId
     For Each mId In menuDict
      myDialogMenu.Checked( mId) = False
     Next
     SelectMenuItem = True
    End Function



    Function GetMenuItemID( menuDict, item)
     ' Return the menuItem ID of the item inside the dictionary.
     Dim mID
     For Each mID In menuDict
      If menuDict( mID) = item Then
       GetMenuItemID = mID
       Exit Function
      End If
     Next
     GetMenuItemID = ""
    End Function

    Sent: Friday, May 27, 2011 12:00 PM

    Subject: Re: Menu Items and Menu Group?

      Bruce,
      We do not expose the information you are asking for.  The reason is
      the menu object we provide is for your own dialogs.  Meaning either
      your entry in our apps menu or the menu bar in your dialog.  In
      either case you are the one that put the entries in the menu so you
      know what is there and how to interact with them.
      Doug
      On 5/27/2011 10:27 AM, BT wrote:



    Hi!



        I still would like to know, but my dictionary function is perfect
    and requires only the items dictionary along with 4 lines of code for
    the function...

            Bruce



    Sent: Friday, May 27, 2011 8:18 AM

    Subject: Menu Items and Menu Group?



    Hi!



        I discovered in my app manager in the help menu that there is no
    property for the size or count inside a menu item list. Is there?



        I wish to deselect or check all items inside one menu list so if I
    check one item all the rest are unchecked.



        I no from other languages ther is usually a way to count all items
    with a built in property and there is none for WE menu
    properties/methods. At least what I see on the property list.



        I attempted the UBound and that either says the method/property
    does not exist or not set...



        Any thoughts would be appreciated for I am at the moent making a
    dictionary list of all items to resolve the issue.



            Bruce



--
Aaron Smith
Web Development * App Development * Product Support Specialist
GW Micro, Inc. * 725 Airport North Office Park, Fort Wayne, IN 46825
260-489-3671 * gwmicro.com

To insure that you receive proper support, please include all past
correspondence (where applicable), and any relevant information
pertinent to your situation when submitting a problem report to the GW
Micro Technical Support Team.

--
Aaron Smith
Web Development * App Development * Product Support Specialist
GW Micro, Inc. * 725 Airport North Office Park, Fort Wayne, IN 46825
260-489-3671 * gwmicro.com

To insure that you receive proper support, please include all past
correspondence (where applicable), and any relevant information
pertinent to your situation when submitting a problem report to the GW
Micro Technical Support Team.


Reply via email to