How to use Dictionaries

Not to drag this on too long...
KM supports arrays and has for quite some time.

No, that's not what I want.

What I want is to associate all my stock tickers with an associated URL. That's ALL. And I achieved that. Problem solved.

If I did want KM to create a record (or struct, or array, if you prefer) I could do that. Just generate a dictionary named with my ticker as the key, and have its value be another dictionary which holds all the key/value pairs holding related info. I would then have a dictionary of dictionaries. I could also have an array of these dictionaries like what you describe. KM makes it relatively easy to get an array of keys, or an array of values, or both from a dictionary. I could then get an array of keys from the dictionary, sort it, and use that sorted list to grab the values from the dictionary. But that's not what I wanted.

And to clarify things a bit, a dictionary is not an array. The Python dictionary definition is similar in other programming languages: "A dictionary is an associative array (also known as hashes). Any key of the dictionary is associated (or mapped) to a value. The values of a dictionary can be any Python data type. So dictionaries are unordered key-value-pairs." This definition applies to KM.

JavaScript doesn't have a structure called a Dictionary, but it has Associative Arrays: "...sometimes this is called a hash or map structure or a dictionary object. An associative array is simply a set of key value pairs." Nothing magic here. KM's Dictionaries are key/value pairs.

Regardless, I'm not writing my project in KM, I'm writing it in Python. KM is just a very handy tool to get some of the work done.

Sorry, but those are pseudo arrays, not true arrays that could contain any data type, like dictionaries.

I understand that. But you asked:

That is the question/issue I was addressing. It is how to use Dictionaries for the more general use case.[quote="thebroz, post:21, topic:8183"]
If I did want KM to create a record (or struct, or array, if you prefer) I could do that. Just generate a dictionary named with my ticker as the key, and have its value be another dictionary which holds all the key/value pairs holding related info. I would then have a dictionary of dictionaries.
[/quote]

That would be great! Please show us a real example of how you would do this.

I never said it was. My example used a JavaScript Variable, which IS an array, to contain multiple objects (dictionaries).

Having said that, if you consider a plist or XML as a dictionary, then a dictionary can in fact contain arrays:

Consider this example (extract) taken from the KM macro plist file, which is a XML file:
Note that there is a top level <array> which contains an <dict>, which in turn contains an <array>.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array> <!-- START OF GROUP LIST -->
	<dict> <!-- START of GROUP 1 -->
		<key>Activate</key>
		<string>Normal</string>
		<key>CreationDate</key>
		<real>461048205.02807498</real>
		<key>CustomIconData</key>
		<string>KMEP-Burning</string>
		<key>Macros</key>	
		<array> 
			<dict>	<!-- START OF MACRO 1 -->
				<key>Actions</key>
				<array>	<!-- START of Action List for Macro 1 -->
					<dict>	<!-- ACTION 1 of Macro 1 -->
						<key>MacroActionType</key>
						<string>SetVariableToText</string>
						<key>Text</key>
						<string>Set in the calling Macro.</string>
						<key>Variable</key>
						<string>SingleLine</string>
					</dict>
				</array>	<!-- END of Action List for Macro 1 -->
				<key>CreationDate</key>
				<real>530147101.03176898</real>
				<key>ModificationDate</key>
				<real>534223708.42322803</real>
				<key>Name</key>
				<string>Execute Macro Parameter</string>
				<key>Triggers</key>
				<array/>	
				<key>UID</key>
				<string>14A0A5C7-58FE-4FEF-B4AC-6212DB0E7736</string>
			</dict>  <!-- END OF MACRO 1 -->
		</array>
		<key>Name</key>
		<string>[TEST]</string>
		<key>ToggleMacroUID</key>
		<string>40691C77-9FA8-43B0-A4FA-80F6664A217A</string>
		<key>UID</key>
		<string>5FC1DC16-E27C-4EBC-9869-9B705B73EAE1</string>
	</dict>	<!-- END OF GROUP 1 -->
</array> <!--> END OF GROUP LIST -->
</plist>

JavaScript DOES have objects, which can be key/value pairs. Same thing as a dictionary. I use them all the time.

Which is fine. As I said above, use the best tool (you know how to use) for the job.

Currently, the only way to interact with dictionaries is via macros? This is not ideal. Would it be possible to build in a dictionary editor similar to the variable viewer like found in the preferences menu?

You should take a look at @DanThomas’s excellent macro: