Help:Array

From Wikiquote
Jump to: navigation, search

This is a copy of the master help page at m:Help:Array. Do not edit this page. Edits will be lost in the next update from the master page. Either edit the master help page for all projects at Meta, or edit the project-specific text at Template:Ph:Array. You are welcome to copy the exact wikitext from the master page at Meta and paste it into this page at any time.


Editing overview

Starting a new page

  1. Page name

Referencing

  1. Links
  2. Piped links
  3. Interwiki linking
  4. Variables
  5. URLs
  6. Anchors

Formatting

  1. Formulas
  2. Lists
  3. Tables
  4. HTML in wikitext
  5. Image & File uploads
  6. Image page

Organizing

  1. Sections
  2. Templates
  3. Categories
  4. Redirects
  5. Namespaces
  6. Renaming (moving) a page

Fixing mistakes and vandalism

  1. Reverting edits
  2. Testing

Saving effort

  1. Editing shortcuts
  2. Editing toolbar
  3. Magic words

Communicating

  1. Edit summary
  2. Talk page
  3. Edit conflict
  4. Minor edit

Special characters

  1. Turkish characters
  2. Romanian characters

Extensions

  1. WikiHiero syntax — warning: lots of images! (for Egyptian hieroglyphs)
  2. EasyTimeline syntax

Frequently Asked Questions


A method to create a data array using templates is as follows. A template, the so-called concatenation template, produces the values of all its parameters. It is called by a data template that assigns all data to the parameters, then erases the values of the parameters of which the names are its own parameters, resulting in erasing all values except the desired one. The root template provides the selection of values to be erased: all parameters are specified for erasure from the list to be displayed, but for the desired one the specification for erasure is itself erased.

Contents

[edit] Language name example

{{langname|de}} gives Template:Langname:

The "root template"

Template:Timc

calls the "data template"

Template:Timc

which calls the "concatenation template"

Template:Timc

[edit] A 24 by 60 array

A concatenation template for general use, with unnamed parameters 1 - 1440, is Template:Tim.

The root template Template:Tim is for a 2D array of size 24 × 60, with index values "00:00" - "23:59". Thus it can also take a time as index value, in particular the result of {{CURRENTTIME}}.

A second set of index values is used in defining the array elements. These index values may or may not be the same as the first set. In the example above they are the same, here they are not, we have the index values 1 - 1440. Thus the template contains 1440 pieces of code of the form "00:04=5". The template is called with two parameters: the array name (i.e. the name of the data template) and the index pair, e.g. "00:04", which can also be seen as a single index.

A small modification fixes the first (part of the) index to 0: Template:Tim.

A matching example data template is Template:Tim. The first part contains 1440 pieces of code of the form "5=abc". The second part contains 1440 pieces of code of the form "=". This part can be reused for other data arrays with these index values.

Template:Timcnl shows that the first part can contain less than 1440 data, while for the second part this is also the case, and this part may contain more than the first part, for convenient expanding of the array by just adding to the first part.

Examples:

{{array1440|city array demo|00:02}} gives Template:Array1440

{{array1440|city array demo|00:03}} gives Template:Array1440

{{array60|city array demo|02}} gives Template:Array60

Example of using array elements as parameters:

{{t2|{{array60|city array demo|01}}|{{array60|city array demo|02}}}} using Template:Timc gives Template:T2

Examples of using a template result as (or in) an array index:

{{array60|city array demo|{{x2|1}}}} gives Template:Array60.

{{array60|city array demo|{{array60|city array demo|16}}}} gives Template:Array60.

[edit] Plain numbers as index values

{{array|square|3}} using Template:Timcnl and Template:Timcnl and Template:Tim gives Template:Array.

Nested:

{{array|square|{{array|square|2}}}} gives Template:Array.

For larger arrays, extend the three lists: k=k, k=data, {{{k }}}=. The fourth list is already available for 1440 index values.

[edit] Other example

{{array|array demo|3}} using Template:Timcnl and Template:Timcnl and Template:Tim gives Template:Array.

[edit] Comparison with other method

The advantage compared to one of the other methods is that unlike that method, no separate auxiliary template is needed for each value of the index used. This makes copying to another project much easier, especially if no export/import feature is available.

On the other hand, in the method on this page enlarging the array, when no preparation for that has been made in advance, requires updating three templates, while the other method requires updating one and creating one.

[edit] Wikiquote-specific content

Edit this Wikiquote- and subject-specific template

[edit] Links to other help pages

Help contents - all pages in the Help namespace: Meta b: c: n: w: q: wikisource wiktionary


Reading: Overview | Go | Search | URL | Namespace | Page name | Section | Link | Backlinks | Piped link | Interwiki link | Redirect | Variable | Category
Tracking changes: Recent | (enhanced) | Related | Watching pages | Page history | Diff | User contributions | Edit summary | Minor edit
Logging in and preferences: Logging in | Preferences | User style
Editing: Overview | New page | Images/files | Image description page | Special characters | Formula | Table | EasyTimeline | Template intro | Renaming (moving) a page | Automatic conversion of wikitext | Talk page | Testing | rlc
Projects: Meta (master page) | Wikibooks | Wikicommons | Wikinews | Wikipedia | Wikiquote | Wikisource | Wiktionary
For other languages see Meta.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox