Difference between revisions of "Command/setdataset"

From Wiki
Jump to navigation Jump to search
m (Fix typo)
 
(4 intermediate revisions by 2 users not shown)
Line 4: Line 4:
 
}}
 
}}
  
 +
== [[Help:Reference|Syntax]] (autogenerated) ==
 +
<syntax>setdataset</syntax>
 
== [[Help:Reference|Syntax]] ==
 
== [[Help:Reference|Syntax]] ==
 
<table cellspacing="4" cellpadding="2" class="cmd">
 
<table cellspacing="4" cellpadding="2" class="cmd">
Line 26: Line 28:
 
== 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.  
 +
 
 +
A middle argument is optional. If provided, it specifies the name (or numerical index) at which the key-value table is stored in the dataset; if it is 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
 
  
<texcode>
+
% Store an anonymous table. It will be stored at point 1.
\setdataset [somedataset] [alpha] [foo=first, bar=second]
+
\setdataset[somedataset][wantscake=yes, wantsdeath=no]
\setdataset [somedataset] [beta]  [foo=first, bar=second]
 
</texcode>
 
  
 +
% Store a table by name
 +
\setdataset[somedataset][catnames][cat1=Georgina, cat2=George]
  
== See also ==
+
% The next anonymous table is stored at point 2.
<!-- something like {{cmd|goto}} -->
+
\setdataset[somedataset][name=Hans Hagen]
  
More detailled explanations and examples can be found under
+
% We can overwrite existing tables, even anonymous ones
[[System_Macros/Key_Value_Assignments|Key-Value Assignments]] section Two-pass data.
+
\setdataset[somedataset][1][wantscake=Yes please., wantsdeath=No thanks.]
  
 +
% Retrieve a stored datum.
 +
Do you want cake? \datasetvariable{somedataset}{1}{wantscake}.
 +
% --> Do you want cake? Yes please.
 +
</texcode>
  
{{cmd|definedataset}},
+
== See also ==
{{cmd|datasetvariable}}
 
  
 +
* {{cmd|definedataset}}
 +
* {{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]].
  
 
== Help from ConTeXt-Mailinglist/Forum ==
 
== Help from ConTeXt-Mailinglist/Forum ==
Line 57: Line 64:
 
{{Forum|{{SUBPAGENAME}}}}
 
{{Forum|{{SUBPAGENAME}}}}
  
[[Category:Commands|setdataset]]
+
[[Category:Command/Datasets|setdataset]]

Latest revision as of 14:49, 13 October 2019

\setdataset

Syntax (autogenerated)

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


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.

A middle argument is optional. If provided, it specifies the name (or numerical index) at which the key-value table is stored in the dataset; if it is omitted, the first anonymous table is stored at index 1, the next at index 2, and so on.

Usage

\definedataset[somedataset]

% Store an anonymous table. It will be stored at point 1.
\setdataset[somedataset][wantscake=yes, wantsdeath=no]

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

% The next anonymous table is stored at point 2.
\setdataset[somedataset][name=Hans Hagen]

% We can overwrite existing tables, even anonymous ones
\setdataset[somedataset][1][wantscake=Yes please., wantsdeath=No thanks.]

% Retrieve a stored datum.
Do you want cake? \datasetvariable{somedataset}{1}{wantscake}.
% --> Do you want cake? Yes please.

See also

Help from ConTeXt-Mailinglist/Forum

All issues with: