Difference between revisions of "Command/datasetvariable"

From Wiki
Jump to navigation Jump to search
(Initial commit)
 
 
(2 intermediate revisions by 2 users not shown)
Line 4: Line 4:
 
}}
 
}}
  
 +
== [[Help:Reference|Syntax]] (autogenerated) ==
 +
<syntax>datasetvariable</syntax>
 
== [[Help:Reference|Syntax]] ==
 
== [[Help:Reference|Syntax]] ==
 
<table cellspacing="4" cellpadding="2" class="cmd">
 
<table cellspacing="4" cellpadding="2" class="cmd">
Line 15: Line 17:
 
<tr valign="top" class="second">
 
<tr valign="top" class="second">
 
     <td class="cmd">{...}</td>
 
     <td class="cmd">{...}</td>
     <td>identifier or number </td>
+
     <td>name or number of table in data set</td>
 
   </tr>
 
   </tr>
 
   <tr valign="top" class="third">
 
   <tr valign="top" class="third">
 
     <td class="cmd">{...}</td>
 
     <td class="cmd">{...}</td>
     <td>key </td>
+
     <td>variable name</td>
 
   </tr>
 
   </tr>
 
</table>
 
</table>
Line 26: Line 28:
 
== Description ==  
 
== Description ==  
  
This command retrieves the values that have been saved with the {{cmd|setdataset}} command. The first argument is the data set name, given by the first argument of {{cmd|setdataset}}. The second argument is an integer if {{cmd|setdataset}} was used with two arguments and an identifier if {{cmd|setdataset}} was used with three arguments. The last argument is the key, which value should be retrieved.
+
<texcode>
 +
\datasetvariable{mydataset}{mytable}{myvariable}
 +
</texcode>
 +
This command retrieves the value of <code>myvariable</code> in the table <code>mytable</code> stored in the dataset <code>mydataset</code>. Two complete examples are shown below.
  
 
== Usage ==
 
== Usage ==
  
 
<texcode>
 
<texcode>
\datasetvariable{somedataset}{1}{foo}
+
% Define a dataset called 'mysteries'
 +
\definedataset[mysteries]
 +
 
 +
% The first anonymous table is stored at position 1, the second at position 2, etc.
 +
\setdataset[mysteries][assistant=Watson]
 +
 
 +
% Retrieving an anonymous table
 +
\datasetvariable{mysteries}{1}{assistant} % Watson
 
</texcode>
 
</texcode>
  
Line 37: Line 49:
  
 
<texcode>
 
<texcode>
\datasetvariable{somedataset}{alpha}{bar}
+
% Define a dataset called 'mysteries'
 +
\definedataset[mysteries]
 +
 
 +
% Store a key-value dataset called 'Doyle'
 +
\setdataset[mysteries][Doyle][detective=Holmes, assistant=Watson, officer=Lestrade]
 +
 
 +
% Retrive the variable 'assistant' from the 'Doyle' table in the 'mysteries' dataset
 +
\datasetvariable{mysteries}{Doyle}{assistant} % Watson
 
</texcode>
 
</texcode>
 
  
 
== See also ==
 
== See also ==
<!-- something like {{cmd|goto}} -->
 
 
More detailled explanations and examples can be found under
 
[[System_Macros/Key_Value_Assignments|Key-Value Assignments]] section Two-pass data.
 
 
  
{{cmd|definedataset}},
+
* {{cmd|definedataset}} to define a dataset for storing key-value tables
{{cmd|setdataset}}
+
* {{cmd|setdataset}} to store key-value tables in a dataset
 +
* 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 56: Line 70:
 
{{Forum|{{SUBPAGENAME}}}}
 
{{Forum|{{SUBPAGENAME}}}}
  
[[Category:Commands|datasetvariable]]
+
[[Category:Command/Datasets|datasetvariable]]

Latest revision as of 14:49, 13 October 2019

\datasetvariable

Syntax (autogenerated)

\datasetvariable{...}{...}{...}
{...}name
{...}name number
{...}key realpage


Syntax

\datasetvariable{...}{...}{...}
{...} name of data set
{...} name or number of table in data set
{...} variable name


Description

\datasetvariable{mydataset}{mytable}{myvariable}

This command retrieves the value of myvariable in the table mytable stored in the dataset mydataset. Two complete examples are shown below.

Usage

% Define a dataset called 'mysteries'
\definedataset[mysteries]

% The first anonymous table is stored at position 1, the second at position 2, etc.
\setdataset[mysteries][assistant=Watson]

% Retrieving an anonymous table
\datasetvariable{mysteries}{1}{assistant}  % Watson

or

% Define a dataset called 'mysteries'
\definedataset[mysteries]

% Store a key-value dataset called 'Doyle'
\setdataset[mysteries][Doyle][detective=Holmes, assistant=Watson, officer=Lestrade]

% Retrive the variable 'assistant' from the 'Doyle' table in the 'mysteries' dataset
\datasetvariable{mysteries}{Doyle}{assistant}  % Watson

See also

  • \definedataset to define a dataset for storing key-value tables
  • \setdataset to store key-value tables in a dataset
  • More detailed explanations and examples can be found in the Key-Value Assignments article, under the section Multi-pass data.


Help from ConTeXt-Mailinglist/Forum

All issues with: