summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/readarray
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-04-19 23:41:18 +0000
committerKarl Berry <karl@freefriends.org>2013-04-19 23:41:18 +0000
commit2c744df230bea4ca067782081c0fe56c5e9820de (patch)
tree6b7472eb679d6c6950058334eac62c7881961b3b /Master/texmf-dist/doc/latex/readarray
parent45e4d75f0b7af7d480d13e4a7cd7411ab5b20a70 (diff)
readarray (19apr13)
git-svn-id: svn://tug.org/texlive/trunk@30048 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/latex/readarray')
-rw-r--r--Master/texmf-dist/doc/latex/readarray/README12
-rw-r--r--Master/texmf-dist/doc/latex/readarray/readarray.pdfbin192524 -> 218668 bytes
-rw-r--r--Master/texmf-dist/doc/latex/readarray/readarray.tex165
3 files changed, 134 insertions, 43 deletions
diff --git a/Master/texmf-dist/doc/latex/readarray/README b/Master/texmf-dist/doc/latex/readarray/README
new file mode 100644
index 00000000000..5ac26875531
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/readarray/README
@@ -0,0 +1,12 @@
+The readarray package allows one to input formatted data into elements
+of a 2-D or 3-D array and to recall that data at will by individual cell
+number. The data can be but need not be numerical in nature. It can
+be, for example, formatted text.
+
+While the package can be used for any application where indexed data is
+called for, the package proves particularly useful when elements of
+multiple arrays must be recallable and dynamically combined at time of
+compilation, rather than in advance.
+
+When data is read from an input file, it may also be accessed by file
+record (1-D access), in addition to 2-D or 3-D array-cell access.
diff --git a/Master/texmf-dist/doc/latex/readarray/readarray.pdf b/Master/texmf-dist/doc/latex/readarray/readarray.pdf
index 68170f72cff..764bfbdc971 100644
--- a/Master/texmf-dist/doc/latex/readarray/readarray.pdf
+++ b/Master/texmf-dist/doc/latex/readarray/readarray.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/readarray/readarray.tex b/Master/texmf-dist/doc/latex/readarray/readarray.tex
index 708a1afe707..e4036d7faff 100644
--- a/Master/texmf-dist/doc/latex/readarray/readarray.tex
+++ b/Master/texmf-dist/doc/latex/readarray/readarray.tex
@@ -1,5 +1,5 @@
\documentclass{article}
-\def\version{1.01}
+\def\version{1.1}
%% Copyright 2013 Steven B. Segletes
%
% This work may be distributed and/or modified under the
@@ -15,6 +15,7 @@
% The Current Maintainer of this work is Steven B. Segletes.
% Revisions:
% v1.01 Documentation revision
+% v1.1 Added \csname record\roman{@row}\endcsname to \readdef
\parskip 1em
\parindent 0em
@@ -52,6 +53,8 @@ The commands included in this package help the user input data, define
it in terms of array elements and recall those elements at will. Those
commands are:\\\itshape
\rl\vb|\readdef{|filename\vb|}{|token\vb|}|\\
+\rl\vb|\showrecord[|error\vb|]{|record number\vb|}|\\
+\rl\vb|\copyrecords{|identifier\vb|}|\\
\rl\vb|\readArrayij{|token\vb|}{|identifier\vb|}{|columns\vb|}|\\
\rl\vb|\readArrayijk{|token\vb|}{|identifier\vb|}{|rows\vb|}{|columns\vb|}|\\
\rl\vb|\Arrayij[|error\vb|]{|identifier\vb|}{|row\vb|}{|column\vb|}|\\
@@ -61,7 +64,9 @@ commands are:\\\itshape
Several strings of fixed name are defined through the use of this
package which are accessible to the user:\\
\rl\vb|\nrows|\\
-\rl\vb|\ncols|
+\rl\vb|\ncols|\\
+\rl\vb|\nrecords|\\
+\rl\vb|\record|\textit{index}
In addition to the strings of fixed name, there are various strings
created whose name is a function of the user-specified data, such
@@ -84,7 +89,7 @@ the following:\\\itshape
\rl\vb|\showargs[|number\vb|]|\\\upshape
\rl\vb|\def\converttilde{|T or F\vb|}|\upshape
-\section{Usage}
+\section{Data Structure}
The first requirement is to lay out a format for the data interface to
this package. The {\rdar} package is set up to digest space-separated data.
@@ -126,13 +131,15 @@ A_{\mathrm{(planes)}\mathrm{(rows)}1} &A_{\mathrm{(planes)}\mathrm{(rows)}2} &A_
\end{array}
\)
+\section{Getting Data into Array Structures\label{s:ex}}
+
One can provide data to be digested by this package in one of two ways:
either through an external file, or by way of ``cut and paste'' into a
\vb|\def|. If one chooses the external file approach, the command
-\vb|\readdef|\margcmd{readdef} is the command to use. The command
-takes two arguments. The first is the file in which the data is stored,
-while the second is the token into which the data will be placed, for
-example
+\vb|\readdef|\margcmd{readdef} is the command which can achieve this
+result. The command takes two arguments. The first is the file in
+which the data is stored, while the second is the token into which the
+data will be placed, for example
\rl\vb|\readdef{data.txt}{\dataA}|
@@ -163,12 +170,20 @@ a \vb|\readdef| will cause the following strings to be set:
\vb|\ncols|\margcmd{ncols} and \vb|\nrows|\margcmd{nrows}, in this
case to values of \vb|4| and \vb|3|, respectively. Such data could
prove useful if the array size is not known in advance.
-
-A generally less preferred, but viable way to make the data available is
-to cut and paste into a \vb|\def|. However, because a blank line is
-not permitted as part of the \vb|\def|, a filler symbol (\vb|%|
-or \vb|\relax|) must be used in its place, if it is desired to visually
-separate planes of data:
+When \verb|\readdef| is invoked, a string
+\verb|\nrecords|\margcmd{nrecords} will also be set to the number of
+file records processed by the \vb|\readdef| command.
+
+In lieu of \verb|\readdef|, a generally less preferred, but viable way
+to make the data available is to cut and paste into a \vb|\def|.
+However, because a blank line is not permitted as part of the \vb|\def|,
+a filler symbol (\vb|%| or \vb|\relax|) must be used in its place, if it
+is desired to visually separate planes of data, as shown in the
+\verb|\def| example at the top of the following page. Note that the
+\vb|%| is also required at the end of the line containing \vb|\def|, in
+order to guarantee that, in this case, \vb|A111| is the first element of
+data (and not a linebreak). However, unlike \vb|\readdef|, this
+definition will set the values of neither \vb|\ncols| nor \vb|\nrows|.
\begin{verbbox}[]
\def{\dataA}{%
@@ -185,16 +200,12 @@ A231 A232 A233 A234
\theverbbox
\end{tabular}
-The \vb|%| is also required at the end of the line containing
-\vb|\def|, in order to guarantee that, in this case, \vb|A111| is
-the first element of data (and not a linebreak). However, unlike
-\vb|\readdef|, this definition will set the values of neither
-\vb|\ncols| nor \vb|\nrows|.
-
Once the data to be placed into an array is available by way of either
-\vb|\readdef| or \vb|\def|, the command to digest the data into an
-array is either \vb|\readArrayij|, in the case of 2-D data, or
-\vb|\readArrayijk|, for 3-D data.
+\vb|\readdef| or \vb|\def|, the command to digest the data into an array
+is either \vb|\readArrayij| (or \verb|\copyrecords|), in the case of 2-D
+data, or \vb|\readArrayijk|, for 3-D data.
+
+\subsection{Creating 2-D Arrays}
In the case of \vb|\readArrayij|\margcmd{readArrayij}, the command
takes three arguments. The first is the token into which the data had
@@ -204,14 +215,35 @@ the last argument is the number of columns in the array. If the data
had been read by way of \vb|\readdef|, the string \vb|\ncols|
may be used to signify this value.
+\subsection{Creating Pseudo-1-D Arrays}
+
+While the {\rdar} package has no explicit provisions for 1-D arrays, one
+could use the 2-D \verb|\readArrayij| command, with the third argument set
+to a value of unity \{1\}, instead of \verb|\ncols|. In this way, each
+space-separated word of the input file will be set to a new data row.
+While this approach is useful for sticking each ``word'' of input data
+into its own single-column data row, the command
+\verb|\copyrecords|\margcmd{copyrecords} can be used to stick the
+individual ``file records'' from the most recent \verb|\readdef| into a
+2-D array of \textbf{single-column width}. The \verb|\copyrecords| command takes
+as its argument an alphabetic string identifier to associate with the
+array of data. Its use accomplishes two things: 1) it allows records
+(rather than words) of a file to be accessed using the general
+\verb|\Arrayij| nomenclature to be discussed shortly; and 2) it saves
+the most recently read file data into its own data structure, so that it
+is not overwritten by a subsequent invocation of \verb|\readdef|.
+
+\clearpage
+\subsection{Creating 3-D Arrays}
+
For the 3-D case, \vb|\readArrayijk|\margcmd{readArrayijk} takes an
-additional argument. The first two arguments are identical to
-\vb|\Arrayij|; namely, the token containing the data and an identifier
-for the array. The third argument is the number of rows in the array,
-while the fourth argument is the number of columns. Likewise, if
-\vb|\readdef| had been used on a properly formed input file, both
-\vb|\nrows| and \vb|\ncols| may be used to supply the third and
-fourth arguments.
+additional argument, in comparison to \verb|\readArrayij|. The first two
+arguments are identical to \vb|\readArrayij|; namely, the token containing
+the data and an identifier for the array. The third argument is the
+number of rows in the array, while the fourth argument is the number of
+columns. Likewise, if \vb|\readdef| had been used on a properly formed
+input file, both \vb|\nrows| and \vb|\ncols| may be used to supply the
+third and fourth arguments.
While it may be easily envisioned that the array data is numerical, this
need not be the case. The data may be text, and even formatted text.
@@ -264,37 +296,44 @@ If, perchance, a row is only partially defined by \vb|\readArrayij| or
a plane is only partially defined by \vb|\readArrayijk|, the partial
data is discarded.
-Also, while the interpretation of hardspaces (\vb|~|) as data is
-specifically designed to allow multi-word data entries, one may choose
-to turn this feature off by setting the flag
+\subsection{Treatment of Hardspaces}
+
+For either the 2-D or 3-D \verb|\readArray| commands, the interpretation
+of hardspaces (\vb|~|) as data is specifically designed to allow
+multi-word data entries. However, one may choose to turn this feature
+off by setting the flag
\rl\vb|\def\converttilde{T}|
which will have the effect of converting hardspaces to regular space
tokens.
+\section{Recalling Data from Array Structures}
+
While one has specified the number of columns and/or rows associated
with the \vb|\readArray...| initialization, those numbers may not yet
be known to the user, if the values employed came from the
-\vb|\readdef| initializations of%
+\vb|\readdef| initializations of
+\vb|\ncols| and \vb|\nrows|. Therefore, the \vb|\readArray...|
\margcmd{{\rmfamily\itshape identifier}CELLS}%
\margcmd{{\rmfamily\itshape identifier}PLANES}%
\margcmd{{\rmfamily\itshape identifier}ROWS}%
\margcmd{{\rmfamily\itshape identifier}COLS}%
-\vb|\ncols| and \vb|\nrows|. Therefore, the \vb|\readArray..|
-commands also set the following strings
+commands also set the following strings:
\itshape\vb|\|identifier\vb|CELLS|, \vb|\|identifier\vb|PLANES|% ,
\vb|\|identifier\vb|ROWS|{\upshape, and}
\vb|\|identifier\vb|COLS|\upshape, where
-\textit{identifier} is the array identifier string. Note that it is the
+\textit{identifier} is the array identifier string that was supplied to
+the \verb|\readarray...| command. Note that it is the
case, for 3-D arrays, that
\rl\itshape\vb|\|identifier\vb|CELLS| $=$ \vb|\|identifier\vb|PLANES|
$\times$ \vb|\|identifier\vb|ROWS| $\times$
\vb|\|identifier\vb|COLS|\upshape
-For the current example, \tobeConjugationCELLS $=$%
-\tobeConjugationPLANES $\times$\tobeConjugationROWS $\times$%
+For the ``tobeConjugation'' example of the prior section,
+\tobeConjugationCELLS $=$\tobeConjugationPLANES
+$\times$\tobeConjugationROWS $\times$%
\tobeConjugationCOLS. Likewise, for 2-D arrays
\rl\itshape\vb|\|identifier\vb|CELLS| $=$ \vb|\|identifier\vb|ROWS|
@@ -313,14 +352,50 @@ column, in the case of the 3-D \vb|\Arrayijk|.
Thus, in the case of the earlier example involving conjugation of the
verb \textit{to be}, the second-person future-perfect tense of the verb
-is given by\\\vb|\Arrayijk{tobeConjugation}{3}{2}{4}|, which is
-``\Arrayijk{tobeConjugation}{3}{2}{4}.''
+is given by\\
+\rl\vb|\Arrayijk{tobeConjugation}{3}{2}{4}|,\\
+which yields ``\Arrayijk{tobeConjugation}{3}{2}{4}.''
+
+For pseudo-1-D arrays, either created with \verb|\copyrecords| or else
+using the \verb|\readarray| command with the third argument set to
+unity, access to these arrays is achieved by way of \verb|\Arrayij|,
+setting the column argument to unity.
+
+There are also strings defined, one for each record that was read from
+the file, with the name
+\verb|\record|\textit{index}\margcmd{record\itshape\rmfamily index},
+where \textit{index} is the record number expressed in roman numerals.
+Thus in the example from section~\ref{s:ex}, \vb|\recordii| would
+contain the string ``\vb|A121 A122 A123 A124|''. However, such syntax
+provides no bounds checking.
+
+An alternate (perhaps preferred) way to access one of the file records
+read during the most recent \verb|\readdef|, in a way which provides
+bounds checking, is to use the \verb|\showrecord|
+command\margcmd{showrecord}. For the section~\ref{s:ex} example, the
+alternative to executing \vb|\recordii| would be to use
+\verb|\showrecord{2}|. The optional argument to this command provides
+an alternative error message if the record requested is out of bounds.
+The default error messages for negative or excessive record numbers are,
+respectively:
+
+\def\nrecords{1}
+\rl\showrecord{-1}\\
+\rl\showrecord{10}
+
+Unlike the \vb|\Arrayij| and \verb|\Arrayijk| commands already
+discussed, the record data from a given file read will only be available
+until the next invocation of \verb|\readdef|. For this reason, the
+command \verb|\copyrecords| was introduced to convert file-record data
+into an array data structure.
While the user is developing his application involving the {\rdar}
package, there may accidentally arise the unintended circumstance where
-an array element is asked for which falls outside the array bounds. By
-default, the package checks for four error conditions that, by default,
-produce the following error messages
+an array element is asked for which falls outside the array bounds.
+Like \verb|\showrecord|, the \verb|\Arrayij| and \verb|\Arrayijk|
+commands also employ bounds checking. These commands check for
+four error conditions that, by default, produce the following error
+messages:
\rl\Arrayijk{tobeConjugation}{-3}{2}{4}\\
\rl\Arrayijk{tobeConjugation}{9}{2}{4}\\
@@ -335,6 +410,8 @@ if any error condition arises. It could be a blank \vb|[]|, a black
box \vb|[\rule{1ex}{1ex}]|, or anything else that makes sense for the
application.
+\section{Alternate Accessing Commands if \texttt{\bs edef} is Required}
+
The\verb|\Arrayij| and \verb|\Arrayijk| commands may, of course, be
placed as arguments of \verb|\def| commands. They, cannot, however, be
placed into an \verb|\edef|. If the user has need to place the
@@ -365,6 +442,8 @@ syntax such as
``\itshape\vb|\|identifier\vb|X|roman-plane\vb|X|roman-row\vb|X|%
roman-column\upshape'' is employed.
+\section{Support Routines}
+
The engine for the {\rdar} package is the \vb|\getargsC|
\margcmd{getargsC} command, based on the \vb|\getargs| command found
in the \textsf{stringstrings} package. This command has been herein