Jump to content

Search the Community

Showing results for tags 'proposal'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. @jpm Maps variable type has been be in beta for years, and only recently it became officially supported. I like the idea of object-oriented maps, and I like the features and simplicity it offers. However, in practice it's too easy to confuse with arrays and other object type, like dictionary. When run some tests, I also encounter the same errors listed here: After some thinking, I think we really do need to distinguish a map from an array. We cannot just use the same "[]" to reference different types of variables. So my propose is like this: ===== To declare a map, you need to declare like this: local $map:[] ; or even simplier: local $map: ":" indicate that this is a map, not an array, and the difference is enough to be seen right away. You can define the number of elements inside. local $map:5 ; Not: local $map:[5] which means create a map with 5 as the first key ; Or $number = 5; local $map:$number means there are 5 empty elements already in the map. ===== To set a map element, you just follow the same rule: $map:0 = "item 1" ; Set the first map element to be "item 1", with or without a key. $map:["key 1"] = "item with key" ; Set a map element with key "key 1" to "item with key", if this key doesn't exist, add a new item in the map. $map:"key 1" = "item with key" ; It's the same as above. $map:[0] = "itme with 0 as key" ; You can use 0 as the key. ===== To reference a map element, you can either use a zero-based index, or a string as the key: $item = $map:0 ; It will return the first item in the map, with or without a key $item = $map:[0] ; It will return a item with key 0 $item = $map:["key 1"] ; It will return the item with key "key 1" $item = $map:"key 1" ; Same as above. ===== more about the number referencing: $number = 5 $item6 = $map:$number ; It will return the 6th item in the map (zero based) $item = $map:[$number] ; It will return the item with the key "5" ======================= The reason we need to add ":" before the "[", is to distinguish what we want to get. Do we want to get the map, or an array? Suppose there is a scenario like this: local $map[] ; declare a map local $array[5] ; declare an array $map[0] = $array $map[0][0] = 123 ; Error here. The above statement "$map[0][0]" created an confusion that's difficult to process. it can mean either: "Set $array[0] to 123 " or "Set $map[0] with key '0' with a new value 123" It will make the program hard to understand, and error prone. So if we adopt the new syntax, the purpose will become easy: $map:0:0 = 123 ; Set the first element $map, which is a map, to first element with value 123 $map:[0]:[0] = 123 ; Set the map element with key 0, which is a map, to element with key 0 to value 123 $map:0[0] = 123 ; Set the first element $map, which is an array, to first data be value 123 $map:[0][0] = 123 ; Set the element in $map with key 0, which is an array, to first data be value 123 $map[0][0] = 123 ; Set the 2D array $map's first data to be 123 $map[0]:0 = 123 ; Set the 1D array $map's first data, which is a map, its first element to be value 123, with or without a key. $map[0]:[0] = 123 ; Set the 1D array $map's first data, which is a map, its element with key 0 to be value 123. To reference map's elements by keys are also easy: $map:"Key 1":"Key 2" = 123 ; Referencing $map["key 1"]["key 2"] $map.key1:"Key 2" = 123; Reference a dictionary object $map's item("key 1"), to have a map with "key 2" value set to 123 $map:key1.key2 = 123 ; Referencing a map element with a key string, which value is key1.key2, and set this element to 123. $map:["key1"].key2 = 123 ; Referencing a map elment with key "key1", which is an object, and set its key2 property to 123. $map.key1.key2 = 123 ; Referencing an object map's property key1.key2, and set it to 123 $map:0:0 ; Referencing the first element in map, which is also a map, the first element I think when doing like this, it will be much easier for Jon to program the maps variable, and we will have a much more precise way to reference and set map and array values. Please leave your comments for this proposal. Thank you !
×
×
  • Create New...