Top
Back: texpoly
Forward: texring
FastBack:
FastForward:
Up: latex_lib
Top: Singular Manual
Contents: Table of Contents
Index: Index
About: About this document

D.9.2.10 texproc

Procedure from library latex.lib (see latex_lib).

Usage:
texproc(fname,pname); fname,pname strings

Assume:
`pname` is a procedure.

Return:
if fname="": string, the proc `pname` in a verbatim environment in LaTeX-typesetting;
otherwise: append this string to the file <fname>, and return nothing.

Note:
preceding ">>" are deleted in fname, and suffix ".tex" (if not given) is added to fname.

Example:
 
LIB "latex.lib";
texproc("","texproc");
==> \begin{verbatim}
==> proc texproc(string fname,string pname)
==> {  
==>   int i,j,k,nl;
==>   string @p,s,t;
==> 
==>   j = 1;
==> 
==>   if (defined(`pname`))
==>   { if (typeof(`pname`)=="proc")
==>     { @p = string(`pname`);
==>       nl = find(@p,newline);
==>       s = "\\begin{verbatim}" + newline;
==>       s = s + "proc " + pname + "(";
==>       i = find(@p,"parameter");       // collecting the parameters
==>       k = find(@p,"alias");           // and the alias arguments
==>       while((i and i < nl) or (k and k < nl))
==>       {
==>         if (i and (k==0  or i<k))
==>         {
==>          j=find(@p,";",i);
==>          t = @p[i+10,j-i-10];
==>          if(i>1){s = s + ",";};
==>          s = s + t;
==>         }
==>         if (k and (i==0  or k<i))
==>         {
==>          j=find(@p,";",k);
==>          t = @p[k,j-k];
==>          if(k>1){s = s + ",";};
==>          s = s + t;
==>         }
==>         i = find(@p,"parameter",j);
==>         k = find(@p,"alias",j);
==>       }
==>       s = s + ")" + newline;
==>      j++;                      // skip one for the newline
==>      i = find(@p,";"+"return();"+newline,j);
==>      if (!(i))
==>      { i = find(@p,";"+"RETURN();"+newline,j); }  // j kann hier weg
==>      s = s + "{" + @p[j,i-j-1] + "}" + newline;
==>      s = s + "\\end{verbatim}" + newline;
==>    }
==>   }
==>   else
==>   { print(" // -- Error: No such proc defined");
==>     return();
==>   }
==>   if(size(fname))
==>   { i=1;
==>     while (fname[i]==">"){i++;}
==>     fname = fname[i,size(fname)-i+1];
==>     if (size(fname)>=4)        // check if filename is ending with ".tex"
==>     { if(fname[size(fname)-3,4]!=".tex") {fname = fname +".tex"; }
==>     }
==>     else {fname = fname + ".tex";}
==>     write(fname,s);
==>   }
==>   else{return(s);}
==> }
==> \end{verbatim}
==> 


Top Back: texpoly Forward: texring FastBack: FastForward: Up: latex_lib Top: Singular Manual Contents: Table of Contents Index: Index About: About this document
            User manual for Singular version 4.3.2, 2023, generated by texi2html.