summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/readarray/readarray.tex
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/readarray/readarray.tex')
-rw-r--r--macros/latex/contrib/readarray/readarray.tex45
1 files changed, 42 insertions, 3 deletions
diff --git a/macros/latex/contrib/readarray/readarray.tex b/macros/latex/contrib/readarray/readarray.tex
index bd9a4aa114..bdbb3bef70 100644
--- a/macros/latex/contrib/readarray/readarray.tex
+++ b/macros/latex/contrib/readarray/readarray.tex
@@ -9,8 +9,22 @@
\def\rdar{\textsf{readarray}}
\def\loi{\textsf{listofitems}}
\def\cmd#1{\texttt{\string\ \unskip#1}}
-\usepackage{readarray}
+\usepackage{readarray,tokcycle}
\usepackage{verbatimbox}
+\newcommand\bverb[1][]{\begingroup\ifx\relax#1\relax
+ \def\tmpA{\allowbreak}\def\tmpB{0}\else
+ \def\tmpA{}\def\tmpB{#1}\fi
+ \catcode`\%=12 \bverbaux}
+\newcommand\bverbaux[2][\allowbreak\textvisiblespace\allowbreak]{%
+ \ttfamily\tokencycle
+ {\expandafter\tctestifx\expandafter{\tmpB##1}{\allowbreak}
+ {\string##1\tmpA}}
+ {\{\processtoks{##1}\}}
+ {\tctestifx{\isiteleven##1}{##1}
+ {\expandafter\tctestifx\expandafter{\tmpB##1}{\allowbreak}
+ {\tcpush{\string##1\isiteleven}}}}
+ {#1}#2\endtokencycle\endgroup}
+\def\isiteleven{\tcpeek\zzz\ifcat\noexpand\zzz A\tcpush{\space}\fi}
\begin{filecontents*}[overwrite]{file1data.txt}
A111 A112 A113 A114
A121 A122 A123 A124
@@ -179,7 +193,11 @@ commands are:
\textup{To select the level of bounds checking on array cell recall:}\\
\rl\vb|\nocheckbounds|\hfill OR\hfill%
\vb|\checkbounds|\hfill OR\hfill%
-\vb|\hypercheckbounds|
+\vb|\hypercheckbounds|\\
+\textup{To ignore blank (or fully commented) records during the
+ course of a record-array read (this can be undone with a false
+ setting):}\\
+\rl\vb|\ignoreblankreadarrayrecordstrue|
\upshape
In these commands, \cmd{}\textit{data-macro} is a control sequence into
@@ -454,6 +472,27 @@ If an array name is reutilized, its prior definitions are cleared,
so that ``old'' data is not inadvertantly retrieved following the
reutilization.
+One option (introduced in v3.1) in this regard is the if-condition%
+ \margcmd{ifignoreblank readarrayrecords}
+ \bverb[.]{\ifignore.blankreadarrayrecords}, which can take on
+ values of either \bverb[\-]{\ignoreblank\-readarrayrecordstrue} or
+ \bverb{\ignoreblankreadarrayrecordsfalse}.
+When set to the true condition, ``blank'' records in the input file
+ (defined either when the record is actually blank or if the first
+ non-blank token in the record is a catcode-14 \verb|%|) will
+ be ignored.
+This setting will only affect the record array itself---the result
+ of any \cmd{readdef} will be unaffected by this setting, except
+ as detailed in the next paragraph.
+
+The only warning to heed when setting
+ \bverb[\-]{\ignoreblankreadarrayrecords\-true} is that the first
+ blank line in a \bverb{\readdef}'ed file is used to set the value
+ of \cmd{nrows}, which can be used to set the row-depth of a 3-D
+ array plane within subsequent invocations of \cmd{readarray}.
+Of course, the array plane's row-depth may always be set
+ manually, in lieu of using \bverb{\nrows}.
+
\subsection{Creating 2-D and 3-D Arrays from Data}
@@ -948,7 +987,7 @@ I am likewise grateful to Ken Kubota, who suggested moving the
\vb|\newread| outside of \vb|\readdef|, so as not to prematurely
exhaust the 16 available file streams.
-\clearpage
+%\clearpage
\section{Code Listing}
\verbfilenobox[\footnotesize]{readarray.sty}