Difference between revisions of "Command/setdataset"

From Wiki
Jump to navigation Jump to search
m (Fix typo)
(better stuff)
Line 26: Line 26:
 
== Description ==  
 
== Description ==  
  
This command is used to store key-value pairs previously defined with {{cmd|definedataset}}. The first argument is the data set name, the last argument is a list of key-value pairs of data that should be saved. The second argument is optional. When it is not used, the data saved in the set is enumerated or when provided, it is the identifier which can be used to address this particular saved key-value pair.
+
This command is used to store key-value tables in a table previously defined with {{cmd|definedataset}}. The first argument is the data set name, the last argument is a list of key-value pairs of data that should be saved. By default the first table is saved at
 +
A middle argument is optional. If provided, it provides the name (or numerical index) at which the key-value table is stored in the dataset; if omitted, the first anonymous table is stored at index 1, the next at index 2, and so on.
  
 
== Usage ==
 
== Usage ==
  
 
<texcode>
 
<texcode>
\setdataset [somedataset] [foo=first, bar=second]
+
\definedataset[somedataset]
</texcode>
 
  
or
+
% Store a table at point 1
 +
\setdataset[somedataset][foo=first, bar=second]
  
<texcode>
+
% Store a table by name
\setdataset [somedataset] [alpha] [foo=first, bar=second]
+
\setdataset[somedataset][catnames][cat1=Georgina, cat2=George]
\setdataset [somedataset] [beta]  [foo=first, bar=second]
 
</texcode>
 
  
 +
% Store an anonymous table at point 2
 +
\setdataset[somedataset][name=Hans Hagen]
  
== See also ==
+
% Retrieve a stored datum.
<!-- something like {{cmd|goto}} -->
+
This is the \datasetvariable{somedataset}{1}{foo} datum.
 +
% --> This is the first datum.
  
More detailled explanations and examples can be found under
+
</texcode>
[[System_Macros/Key_Value_Assignments|Key-Value Assignments]] section Two-pass data.
 
  
 +
== See also ==
  
{{cmd|definedataset}},
+
* {{cmd|definedataset}},
{{cmd|datasetvariable}}
+
* {{cmd|datasetvariable}}
 +
* More detailed explanations and examples can be found in the Key-Value Assignments article, under the section [[System_Macros/Key_Value_Assignments#Multi-pass data|Multi-pass data]].
  
  
Line 57: Line 60:
 
{{Forum|{{SUBPAGENAME}}}}
 
{{Forum|{{SUBPAGENAME}}}}
  
[[Category:Commands|setdataset]]
+
[[Category:Command/Datasets|setdataset]]

Revision as of 22:56, 26 April 2012

\setdataset

Syntax

\setdataset[...][...][...,...=...,...]
[...] name
[...] name
[...,...=...,...]


Description

This command is used to store key-value tables in a table previously defined with \definedataset. The first argument is the data set name, the last argument is a list of key-value pairs of data that should be saved. By default the first table is saved at A middle argument is optional. If provided, it provides the name (or numerical index) at which the key-value table is stored in the dataset; if omitted, the first anonymous table is stored at index 1, the next at index 2, and so on.

Usage

\definedataset[somedataset]

% Store a table at point 1
\setdataset[somedataset][foo=first, bar=second]

% Store a table by name
\setdataset[somedataset][catnames][cat1=Georgina, cat2=George]

% Store an anonymous table at point 2
\setdataset[somedataset][name=Hans Hagen]

% Retrieve a stored datum.
This is the \datasetvariable{somedataset}{1}{foo} datum.
% --> This is the first datum.

See also


Help from ConTeXt-Mailinglist/Forum

All issues with: