summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/rubik/rubikrotation.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-09-25 23:12:16 +0000
committerKarl Berry <karl@freefriends.org>2015-09-25 23:12:16 +0000
commit97e34175d0f5e100422fbd133cadfcf6f5e944e6 (patch)
tree11f29e6d9beb227b762da99c70f81b369733d71a /Master/texmf-dist/tex/latex/rubik/rubikrotation.sty
parentead3792e2d57305d0777008c5073968c36ec7ba3 (diff)
rubik (25sep15)
git-svn-id: svn://tug.org/texlive/trunk@38457 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/rubik/rubikrotation.sty')
-rw-r--r--Master/texmf-dist/tex/latex/rubik/rubikrotation.sty116
1 files changed, 66 insertions, 50 deletions
diff --git a/Master/texmf-dist/tex/latex/rubik/rubikrotation.sty b/Master/texmf-dist/tex/latex/rubik/rubikrotation.sty
index bbb8d0f1a43..6a8e25d6561 100644
--- a/Master/texmf-dist/tex/latex/rubik/rubikrotation.sty
+++ b/Master/texmf-dist/tex/latex/rubik/rubikrotation.sty
@@ -9,7 +9,8 @@
%% -----------------------------------------------------------------
%% Authors: RWD Nickalls (dick@nickalls.org)
%% and Apostolos Syropoulos (asyropoulos@yahoo.com)
-%% Copyright January 2014 RWD Nickalls and A Syropoulos
+%%
+%% Copyright 25 September 2015 RWD Nickalls and A Syropoulos
%%
%%
%% This work may be distributed and/or modified under the
@@ -46,8 +47,8 @@
%% Right brace \} Tilde \~}
-\def\RRfileversion{2.0}%
-\def\RRfiledate{2014/01/20}%
+\def\RRfileversion{3.0}%
+\def\RRfiledate{2015/09/25}%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{rubikrotation}[\RRfiledate\space (v\RRfileversion)]
\@ifpackageloaded{rubikcube}{}{%
@@ -57,14 +58,15 @@
\typeout{---rubikrotation requires the fancyvrb package%
for VerbatimInput{} command.}%
\RequirePackage{fancyvrb}}
-\newcommand{\rubikrotation}{\textsf{rubikrotation}}
+\newcommand{\rubikrotation}{\textsc{rubikrotation}}
+\newcommand{\Rubikrotation}{\textsc{Rubikrotation}}
+\newcommand{\@print}[1]{\immediate\write\outfile{#1}}
{\catcode`\%=12 \global\def\rubikpercentchar{%}}%
\newcommand{\@comment}{\rubikpercentchar\rubikpercentchar\space}%
\newcommand{\@commentone}{\rubikpercentchar}%
-%% We need a simple print command for writing comments to a file.
-\newcommand{\@print}[1]{\immediate\write\outfile{#1}}
-\newcommand{\rubikperlname}{rubikrotation.pl}
-\newcommand{\rubikperlcmd}{perl \rubikperlname}
+\newcommand{\rubikperlname}{rubikrotation}
+\newcommand{\rubikperlcmd}{\rubikperlname\space%
+ -i rubikstate.dat -o rubikstateNEW.dat}
\typeout{---checking for config file (rubikrotation.cfg)...}
\IfFileExists{rubikrotation.cfg}{%
\input{rubikrotation.cfg}%
@@ -73,19 +75,15 @@
\typeout{---cleaning file rubikstateNEW.dat}%
\newwrite\outfile%
\immediate\openout\outfile=rubikstateNEW.dat%
-\@print{\@comment rubikstateNEW.dat (by TeX)}%
+\@print{\@comment rubikstateNEW.dat}%
\immediate\closeout\outfile%
\typeout{---creating file rubikstateERRORS.dat}%
\newwrite\outfile%
\immediate\openout\outfile=rubikstateERRORS.dat%
\@print{\@comment rubikstateERRORS.dat}%
-\typeout{---checking for Perl script \rubikperlname...}
- \IfFileExists{\rubikperlname}{%
- \typeout{---\rubikperlname\space exists OK}%
- }{\typeout{** ERROR: cannot find Perl program \rubikperlname}%
- \@print{\@comment ** ERROR: cannot find Perl program \rubikperlname}}%
+\@print{\@comment ---(RR.sty v\RRfileversion): comments output by Perl script}%
\immediate\closeout\outfile%
-\typeout{---setting up newwrite for rubikrotation to use...}%
+\typeout{---setting up newwrite for rubikrotation.sty to use...}%
\newwrite\outfile%
\newcommand{\@openstatefile}{\immediate\openout\outfile=rubikstate.dat}
\newcommand{\@closestatefile}{\immediate\closeout\outfile}
@@ -98,63 +96,81 @@
\@print{back,\Blt,\Bmt,\Brt,\Blm,\Bmm,\Brm,\Blb,\Bmb,\Brb}%
\@print{checkstate}%
}
-\newcommand{\RubikRotation}[1]{\IfFileExists{\rubikperlname}{%
+\newcommand{\SaveRubikState}[1]{%
+\typeout{---NEW save command------------------}%
+\typeout{---command = SaveRubikState{#1}}%
+\typeout{---saving Rubik state data to file #1}%
+\immediate\openout\outfile=#1%
+\@print{\@comment filename: #1\@commentone}%
+\@print{\string\RubikFaceUp%
+ {\Ult}{\Umt}{\Urt}{\Ulm}{\Umm}{\Urm}{\Ulb}{\Umb}{\Urb}\@commentone}%
+\@print{\string\RubikFaceDown%
+ {\Dlt}{\Dmt}{\Drt}{\Dlm}{\Dmm}{\Drm}{\Dlb}{\Dmb}{\Drb}\@commentone}%
+\@print{\string\RubikFaceLeft%
+ {\Llt}{\Lmt}{\Lrt}{\Llm}{\Lmm}{\Lrm}{\Llb}{\Lmb}{\Lrb}\@commentone}%
+\@print{\string\RubikFaceRight%
+ {\Rlt}{\Rmt}{\Rrt}{\Rlm}{\Rmm}{\Rrm}{\Rlb}{\Rmb}{\Rrb}\@commentone}%
+\@print{\string\RubikFaceFront%
+ {\Flt}{\Fmt}{\Frt}{\Flm}{\Fmm}{\Frm}{\Flb}{\Fmb}{\Frb}\@commentone}%
+\@print{\string\RubikFaceBack%
+ {\Blt}{\Bmt}{\Brt}{\Blm}{\Bmm}{\Brm}{\Blb}{\Bmb}{\Brb}\@commentone}%
+\immediate\closeout\outfile%
+\typeout{-----------------------------------------}%
+}%
+%% Two macros detailed by Feuersaenger (2015)
+\long\def\@countingloop#1 in #2:#3#4{%
+ #1=#2 %
+ \@loopcounter{#1}{#3}{#4}%
+}
+%%--------------------------
+\long\def\@loopcounter#1#2#3{%
+ #3%
+ \ifnum#1=#2 %
+ \let\next=\relax%
+ \else
+ \advance#1 by1 %
+ \def\next{\@loopcounter{#1}{#2}{#3}}%
+ \fi
+ \next
+}
+\newcommand{\RubikRotation}[2][1]{%
\typeout{---NEW rotation command------------------}%
\typeout{---command = RubikRotation{#1}}%
- \typeout{---Perl script \rubikperlname\space exists OK}%
\typeout{---writing current Rubik state to file rubikstate.dat}%
\@openstatefile% open data file
\@print{\@comment filename: rubikstate.dat}%
+ \@print{\@comment written by rubikrotation.sty%
+ =v\RRfileversion\space (\RRfiledate)}%
\@printrubikstate%
- \@print{rotation,#1}%
+%% countingloop code from Feuersaenger (2015)
+ \newcount\ourRRcounter%
+ \@countingloop{\ourRRcounter} in 1:{#1}{%
+ \immediate\write\outfile{rotation,#2}}%
\@closestatefile% close data file
- \typeout{---running Perl script}%
+ \typeout{---running Perl script (rubikrotation)}%
\immediate\write18{\rubikperlcmd}%
- \typeout{---inputting NEW datafile (from Perl)}%
+ \typeout{---inputting NEW datafile (written by Perl script)}%
\input{rubikstateNEW.dat}%
\typeout{-----------------------------------------}%
- }{\typeout{** ERROR: \rubikperlname\space does not exist}%
-}}
+ }
\newcommand{\ShowRubikErrors}{%
\typeout{---ShowRubikErrors: inputting file rubikstateERRORS.dat}%
- \VerbatimInput{rubikstateERRORS.dat}}
-\newcommand{\CheckRubikState}{\IfFileExists{\rubikperlname}{%
+ \VerbatimInput{rubikstateERRORS.dat}%
+ }
+\newcommand{\CheckRubikState}{%
\typeout{---NEW check command------------------}%
\typeout{---command = CheckRubikState}%
- \typeout{---Perl script \rubikperlname\space exists OK}%
\typeout{---writing current Rubik state to file rubikstate.dat}%
\@openstatefile% opens data file
\@print{\@comment filename: rubikstate.dat}%
\@printrubikstate%
\@closestatefile% close data file
- \typeout{---running Perl script}%
+ \typeout{---running Perl script (rubikrotation)}%
\immediate\write18{\rubikperlcmd}%
- \typeout{---inputting NEW datafile (from Perl)}%
+ \typeout{---inputting NEW datafile (written by Perl script)}%
\input{rubikstateNEW.dat}%
\typeout{-----------------------------------------}%
- }{\typeout{** ERROR: \rubikperlname\space does not exist}%
-}}
-\newcommand{\SaveRubikState}[1]{%
-\typeout{---NEW save command------------------}%
-\typeout{---command = SaveRubikState{#1}}%
-\typeout{---saving Rubik state data to file #1}%
-\immediate\openout\outfile=#1%
-\@print{\@comment filename: #1\@commentone}%
-\@print{\string\RubikFaceUp%
- {\Ult}{\Umt}{\Urt}{\Ulm}{\Umm}{\Urm}{\Ulb}{\Umb}{\Urb}\@commentone}%
-\@print{\string\RubikFaceDown%
- {\Dlt}{\Dmt}{\Drt}{\Dlm}{\Dmm}{\Drm}{\Dlb}{\Dmb}{\Drb}\@commentone}%
-\@print{\string\RubikFaceLeft%
- {\Llt}{\Lmt}{\Lrt}{\Llm}{\Lmm}{\Lrm}{\Llb}{\Lmb}{\Lrb}\@commentone}%
-\@print{\string\RubikFaceRight%
- {\Rlt}{\Rmt}{\Rrt}{\Rlm}{\Rmm}{\Rrm}{\Rlb}{\Rmb}{\Rrb}\@commentone}%
-\@print{\string\RubikFaceFront%
- {\Flt}{\Fmt}{\Frt}{\Flm}{\Fmm}{\Frm}{\Flb}{\Fmb}{\Frb}\@commentone}%
-\@print{\string\RubikFaceBack%
- {\Blt}{\Bmt}{\Brt}{\Blm}{\Bmm}{\Brm}{\Blb}{\Bmb}{\Brb}\@commentone}%
-\immediate\closeout\outfile%
-\typeout{-----------------------------------------}%
-}%
+ }
\endinput
%%
%% End of file `rubikrotation.sty'.