Dplvar: Difference between revisions

320 bytes added ,  2 years ago
m
Make this a bit easier to understand
imported>FrozenPlum
mNo edit summary
imported>FrozenPlum
m (Make this a bit easier to understand)
Line 2:
 
==Syntax==
'''Sets one''' symbolic variable name and assign a value:
<pre><nowiki>
<pre>
(1) {{#dplvar:set |name1|value1|name2|value2|..|..}}
(2) {{#dplvar:defaultset|namevarname|valuevalueofvar}}
</pre>
(3) {{#dplvar: name}}
</nowiki></pre>
 
'''Sets multiple''' symbolic variable names '''and assigns''' values to them (one after the other):
==Effect==
<pre>
(1) assigns the values to symbolic variable names.
(1) {{#dplvar:set |name1|value1|name2|value2|..|..}}
(2) assigns the value only if the variable is empty / has not been used so far.
</pre>
(3) returns the current value of the variable.
 
(2)'''Assigns''' assigns thea value '''only if the variable is empty / has not been used''' so far.:
The variables can be set and retrieved from an article page or from templates used in that article.
<pre>
{{#dplvar:default|aname|aaaavalue}}
</pre>
 
(3) returns'''Returns''' the current value of the variable.:
<pre>
(3) {{#dplvar: name}}
</pre>
{{note|The variables can be set and retrieved from an article page or from templates used in that article.}}
 
==Example==
<pre><nowiki>
{{#dplvar:set|a|x|b|y|c|z<!--empty-->}} {{#dplvar:default|a|aaaa}} {{#dplvar:default|c|cccc}} {{#dplvar:default|d|dddd}}
</pre>
{{#dplvar:default|a|aaaa}}
{{#dplvar:set|a|x|b|y|c|<!--empty-->}} {{#dplvar:default|a|aaaa}} {{#dplvar:default|c|cccc}} {{#dplvar:default|d|dddd}}
 
a={{#dplvar:a}}
'''Result:'''
b={{#dplvar:b}}
c* a={{#dplvar:ca}}
d* b={{#dplvar:db}}
a* c={{#dplvar:ac}}
</nowiki></pre>
b* d={{#dplvar:bd}}
{{#dplvar:set|a|x|b|y|c|z}} {{#dplvar:default|a|aaaa}} {{#dplvar:default|d|dddd}}
 
a={{#dplvar:a}}
'''Notes:'''
b={{#dplvar:b}}
* Variable "c" was set to "cccc" because it was set but with an empty note (empty value).
c={{#dplvar:c}}
* Variable "d" was set to "dddd" because it was not already set.
d={{#dplvar:d}}
 
[[Category:Other Modules]]
Anonymous user