User Tools

Site Tools



This shows you the differences between two versions of the page.

Link to this comparison view

harlowe:dataentries [2017/10/09 20:39] (current)
Line 1: Line 1:
 +**(dataentries:​ // [[harlowe:​Datamap|datamap]]//​) -> //​[[harlowe:​Array|array]]//​**
 +This takes a [[harlowe:​datamap|datamap]],​ and returns an [[harlowe:​array|array]] of its name/value pairs. Each pair
 +is a datamap that only has "​name"​ and "​value"​ data. The pairs are ordered by their name.
 +=== Example usage: ===
 +  * ''​%%(datapairs:​ (dm:'​B',​24,​ '​A',​25))%%''​ produces the following array:
 +''​%%(a:​ (dm: "​name",​ "​A",​ "​value",​ 25), (dm: "​name",​ "​B",​ "​value",​ 24))%%''​
 +  * ''​%%(altered:​ _entry via _entry'​s name + ":"​ + _entry'​s value, ...(datapairs:​ $m))%%''​ creates
 +an array of [[harlowe:​string|string]] from the $m datamap'​s names and values.
 +=== Rationale: ===
 +There are occasions where operating on just the names, or the values, of
 +a datamap isn't good enough - you'll want both. Rather than the verbose process
 +of taking the [[harlowe:​datanames|(datanames:​)]] and [[harlowe:​datavalues|(datavalues:​)]] arrays and using them [[harlowe:​interlaced|(interlaced:​)]]
 +with each other, you can use this macro instead, which allows the name and value of
 +each entry to be referenced using "​name"​ and "​value"​ properties.
 +=== See also: ===
 +[[harlowe:​datanames|(datanames:​)]],​ [[harlowe:​datavalues|(datavalues:​)]]
harlowe/dataentries.txt ยท Last modified: 2017/10/09 20:39 (external edit)