该帮助的版本不再更新,请参见https://www.jmp.com/support/help/zh-cn/15.2 获取最新的版本.


cary = Associative Array();
cary["state"] = "NC";
cary["population"] = 116234;
cary["weather"] = "cloudy";
cary["population"] += 10;
cary["weather"] = "sunny";
cary["high schools"] = {"Cary", "Green Hope", "Panther Creek"};
N Items( cary );
注意: 
Insert() and Remove() return a named copy of the given associative array with the key-value pair added or removed.
Insert Into() and Remove From() add or remove the key-value pairs directly from the given associative array.
Insert() and Insert Into() take three arguments: the associative array, a key, and a value.
Remove() and Remove From() take two arguments: the associative array and a key.
The following examples illustrate Insert() and Insert Into():
newcary = Insert( cary, "time zone", "Eastern" );
Show( cary, newcary );
Insert Into(cary, "county", "Wake");
Show( cary );
Note that cary <<Insert is a message sent to an associative array that does the same thing as the function Insert Into(). For example, these two statements are equivalent:
cary << Insert( "county", "Wake" );
Insert Into( cary, "county", "Wake" );
The following examples illustrate Remove() and Remove From():
newcary = Remove( cary, "high schools" );
Show( cary, newcary );
Remove From( cary, "weather" );
Show( cary );
Note that aa << Remove is a message sent to an associative array that does the same thing as the function Remove From(). For example, these two statements are equivalent:
cary << Remove( "weather" );
Remove From( cary, "weather" );
cary = Associative Array();
cary["state"] = "NC";
cary["population"] = 116234;
cary["weather"] = "cloudy";
cary["population"] += 10;
cary["weather"] = "sunny";
cary["high schools"] = {"Cary", "Green Hope", "Panther Creek"};
Contains(cary, "high schools");
cary << Get Keys;
cary << Get Values;
cary << Get Values({"state", "population"});
To see a value for a single key, use the <<Get Value message. Specify only one key and do not place it in a list.
cary << Get Value("weather");
cary << Get Contents;
注意:Using the <<Get Contents message, the returned list does not include the default value. Keys are listed alphabetically.
To iterate through as associative array, use the <<First and <<Next messages. <<First returns the first key in the associative array. <<Next(key) returns the key that follows the key that is given as the argument.
total = N Items( cary );
For( i = 1, i <= total, i++,
nextkey = cary << Next( currentkey );
Remove From( cary, currentkey );
Show( cary );