Mercurial > hg > ltpda
comparison m-toolbox/html_help/help/ug/plist_create_content.html @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 <p> | |
2 Parameters can be grouped together into parameter lists (<tt>plist</tt>). | |
3 </p> | |
4 | |
5 <ul> | |
6 <li><a href="plist_create.html#direct">Creating parameter lists directly</a></li> | |
7 <li><a href="plist_create.html#append">Appending parameters to a parameter list</a></li> | |
8 <li><a href="plist_create.html#find">Finding parameters in a parameter list</a></li> | |
9 <li><a href="plist_create.html#remove">Removing parameters from a parameter list</a></li> | |
10 <li><a href="plist_create.html#set">Setting parameters in a parameter list</a></li> | |
11 <li><a href="plist_create.html#combine">Combining multiple parameter lists</a></li> | |
12 </ul> | |
13 | |
14 | |
15 <!-- From parameters --> | |
16 <hr> | |
17 <h3><a name="params"></a>Creating parameter lists from parameters.</h3> | |
18 | |
19 | |
20 <!-- Direct --> | |
21 <hr> | |
22 <h3><a name="direct"></a>Creating parameter lists directly.</h3> | |
23 <p> | |
24 You can also create parameter lists directly using the following constructor format:</p> | |
25 <div class="fragment"><pre> | |
26 pl = plist(<span class="string">'a'</span>, 1, <span class="string">'b'</span>, <span class="string">'hello'</span>) | |
27 </pre></div> | |
28 will result in the following output | |
29 <div class="fragment"><pre> | |
30 ----------- plist 01 ----------- | |
31 n params: 2 | |
32 ---- param 1 ---- | |
33 key: A | |
34 val: 1 | |
35 ----------------- | |
36 ---- param 2 ---- | |
37 key: B | |
38 val: 'hello' | |
39 ----------------- | |
40 description: | |
41 UUID: 9cc7d1f1-6ca3-477b-a6cc-2629d52579e6 | |
42 -------------------------------- | |
43 </pre></div> | |
44 | |
45 <!-- Append --> | |
46 <hr> | |
47 <h3><a name="append"></a>Appending parameters to a parameter list.</h3> | |
48 <p> | |
49 Additional parameters can be appended to an existing parameter list using the <tt>append</tt> | |
50 method:</p> | |
51 <div class="fragment"><pre> | |
52 pl = append(pl, <span class="string">'c'</span>, 3) <span class="comment">% append a third parameter</span> | |
53 </pre></div> | |
54 will result in the following output | |
55 <div class="fragment"><pre> | |
56 ----------- plist 01 ----------- | |
57 n params: 3 | |
58 ---- param 1 ---- | |
59 key: A | |
60 val: 1 | |
61 ----------------- | |
62 ---- param 2 ---- | |
63 key: B | |
64 val: 'hello' | |
65 ----------------- | |
66 ---- param 3 ---- | |
67 key: C | |
68 val: 3 | |
69 ----------------- | |
70 -------------------------------- | |
71 </pre></div> | |
72 | |
73 | |
74 <!-- Access --> | |
75 <hr> | |
76 <h3><a name="find"></a>Finding parameters in a parameter list.</h3> | |
77 <p> | |
78 Accessing the contents of a <tt>plist</tt> can be achieved in two ways: | |
79 </p> | |
80 <div class="fragment"><pre> | |
81 p1 = pl.params(1); <span class="comment">% get the first parameter</span> | |
82 val = find(pl, <span class="string">'b'</span>); <span class="comment">% get the second parameter</span> | |
83 </pre></div> | |
84 <p> | |
85 If the parameter name ('key') is known, then you can use the <tt>find</tt> method to | |
86 directly retrieve the value of that parameter. | |
87 </p> | |
88 | |
89 <!-- Remove --> | |
90 <hr> | |
91 <h3><a name="remove"></a>Removing parameters from a parameter list.</h3> | |
92 <p> | |
93 You can also remove parameters from a parameter list: | |
94 <div class="fragment"><pre> | |
95 pl = remove(pl, 2) <span class="comment">% Remove the 2nd parameter in the list</span> | |
96 pl = remove(pl, <span class="string">'a'</span>) <span class="comment">% Remove the parameter with the key 'a'</span> | |
97 </pre></div> | |
98 </p> | |
99 | |
100 <!-- Set --> | |
101 <hr> | |
102 <h3><a name="set"></a>Setting parameters in a parameter list.</h3> | |
103 <p> | |
104 You can also set parameters contained in a parameter list: | |
105 <div class="fragment"><pre> | |
106 pl = plist(<span class="string">'a'</span>, 1, <span class="string">'b'</span>, <span class="string">'hello'</span>) | |
107 pl = pset(pl, <span class="string">'a'</span>, 5, <span class="string">'b'</span>, <span class="string">'ola'</span>); <span class="comment">% Change the values of the parameter with the keys 'a' and 'b'</span> | |
108 </pre></div> | |
109 </p> | |
110 | |
111 | |
112 <!-- Combine --> | |
113 <hr> | |
114 <h3><a name="combine"></a>Combining multiple parameter lists.</h3> | |
115 | |
116 <p> | |
117 Parameter lists can be combined: | |
118 <div class="fragment"><pre> | |
119 pl = combine(pl1, pl2) | |
120 </pre></div> | |
121 If <tt>pl1</tt> and <tt>pl2</tt> contain a parameter with the same key name, the output <tt>plist</tt> contains a parameter with that name but with the value from the first parameter list input. | |
122 </p> | |
123 |