Secciones de la página

Funciones de macro-expansión tme. tol

Funciones

Real TmeFile()

Real TmeFile()

Set TmeEvalMacros()

Set TmeGetMacros()

Set TmeGetMacros()

Set TmeShareMacros()

Text TmeExpandFile()

Text TmeExpandFile()

Text TmeFormat()

Text TmePst()

Text TmeSubMacros()

Tol

Artículos del sitio

Presentación de Tol

Todos los programas

Simuladores visuales

Sitios que me gustan

Por categorías

Algoritmia

Búsqueda y ordenación

Computación fisiológica

Editorial y edición

Gráficos de datos

Herramientas y utilidades

Hipertexto

Informática forense

Lectura óptica de datos

Metaprogramación

No determinista

Ofimática

Recursión e iteración

Reglas y restricciones

Series y estadística









Funciones de macro-expansión tme.tol

Funciones que soportan la macro-expansión del lenguaje Tol. Esto es embeber expresiones Tol dentro de otros lenguajes, como por ejemplo, dentro de Html, para luego evaluarlas tantas veces como se requiera y expandir el resultado de dicha evaluación como si fuera una macro.

Las funciones de esta página están ordenadas de forma alfabética por las diferentes gramáticas del lenguaje Tol ( Text, Set, Serie, Anything, Code, Date, Real,...) y, dentro de cada gramática, por el nombre de la función. Pueden encontrarse 2 o más funciones con idéntico nombre, pero con distintas maneras de programarse o con diferentes comentarios en diferentes idiomas, estas funciones aparecerán unas a continuación de las otras.

Real TmeFile() de Ediciones.aContracorriente

//////////////////////////////////////////////////////////////////////////////
Real TmeFile(Text inpFil, // Input file
             Text outFil) // Output file
//////////////////////////////////////////////////////////////////////////////
{ If(TmeExpandFile(TmeIni, TmeEnd, inpFil, outFil) != "", TRUE, FALSE) };
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Easy way to call TmeExpandFile() with the default values and behaviour.
Returns true if some text was generated.",
TmeFile);
//////////////////////////////////////////////////////////////////////////////

  
//////////////////////////////////////////////////////////////////////////////
Text TmePut(Text codTol) // Tol programing language code
//////////////////////////////////////////////////////////////////////////////
{ TmeIni+" "+codTol+" "+TmeEnd };
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns a Tol code inside Tme brackets.",
TmePut);
//////////////////////////////////////////////////////////////////////////////

Real TmeFile() de Omr.Forms

//////////////////////////////////////////////////////////////////////////////
Real TmeFile(Text inpFil, // Input file
             Text outFil) // Output file
//////////////////////////////////////////////////////////////////////////////
{ If(TmeExpandFile(TmeIni, TmeEnd, inpFil, outFil) != "", TRUE, FALSE) };
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Easy way to call TmeExpandFile() with the default values and behaviour.
Returns true if some text was generated.",
TmeFile);
//////////////////////////////////////////////////////////////////////////////

Set TmeEvalMacros() de iForense

//////////////////////////////////////////////////////////////////////////////
Set TmeEvalMacros(Set codSet) // A set with Tol code that returs text
//////////////////////////////////////////////////////////////////////////////
{
  EvalSet(codSet, Text(Text codEle)
  {                                 // All the evaluations at the same level,
    Anything retVal = Eval(codEle); // can't share the definitions
    TmeFormat(retVal)               // Try to convert to text
  })
};  
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns a set with the text results of all macros. This secuential evaluation
does not let to share functions and variables between macros.",
TmeEvalMacros);
//////////////////////////////////////////////////////////////////////////////

Set TmeGetMacros() de Omr.Forms

//////////////////////////////////////////////////////////////////////////////
Set TmeGetMacros(Text tagIni, // Initial tag
                 Text tagEnd, // Ending tag
                 Text codTxt) // Other programing language code
//////////////////////////////////////////////////////////////////////////////
{
  Text repTxt = Replace(codTxt, tagIni, TmeSep);
  Set  linSet = Tokenizer(repTxt, TmeSep);
  Real lenSet = Card(linSet);
  If(lenSet <= 1, Empty, // There aren't macros
  {
    Set For(2, lenSet, Text(Real posLin)
    {
      Text linTxt = linSet[posLin];
      Real posEnd = TextFind(linTxt, tagEnd, 1);
      If(posEnd <= 1, "", // Without ending (0) or not code inside (1)
                      Sub(linTxt, 1,posEnd-1))
    })
  })
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna un conjunto con todo el codigo entre los tags inicial y final.",
TmeGetMacros);
//////////////////////////////////////////////////////////////////////////////

Set TmeGetMacros() de iForense

//////////////////////////////////////////////////////////////////////////////
Set TmeGetMacros(Text tagIni, // Initial tag
                 Text tagEnd, // Ending tag
                 Text codTxt) // Other programing language code
//////////////////////////////////////////////////////////////////////////////
{
  Text repTxt = Replace(codTxt, tagIni, TmeSep);
  Set  linSet = Tokenizer(repTxt, TmeSep);
  Real lenSet = Card(linSet);
  If(lenSet <= 1, Empty, // There are not macros
  {
    Set For(2, lenSet, Text(Real posLin)
    {
      Text linTxt = linSet[posLin];
      Real posEnd = TextFind(linTxt, tagEnd, 1);
      If(posEnd <= 1, "", // Without ending (0) or not code inside (1)
                      Sub(linTxt, 1,posEnd-1))
    })
  })
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns a set with all codes inside the initial en the ending tags.",
TmeGetMacros);
//////////////////////////////////////////////////////////////////////////////

Set TmeShareMacros() de Antonio.Salmeron

//////////////////////////////////////////////////////////////////////////////
Set TmeShareMacros(Set  codSet, // Set of tol codes
                   Real codPos) // Position inside codSet (recursion counter)
//////////////////////////////////////////////////////////////////////////////
{
  Real lstPos = Card(codSet);
  If(codPos > lstPos, Empty, // Nothing to do
  {                                  // Evaluations at different stack levels,
    Anything retVal = Eval(codSet[codPos]); // can inherit definitions
    Text txtFmt = TmeFormat(retVal);        // Try to convert to text
    [[ txtFmt ]] << TmeShareMacros(codSet, codPos+1) // Recursion
  })
};  
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns a set with the text results of all macros. This recursive evaluation
lets to share definitions, functions and variables between macros.",
TmeShareMacros);
//////////////////////////////////////////////////////////////////////////////

Text TmeExpandFile() de Omr.Forms

//////////////////////////////////////////////////////////////////////////////
Text TmeExpandFile(Text tagIni, // Initial tag
                   Text tagEnd, // Ending tag
                   Text inpFil, // Input file
                   Text outFil) // Output file
//////////////////////////////////////////////////////////////////////////////
{
  Text codTxt = ReadFile(inpFil);
  Text outTxt = TmeSubMacros(tagIni, tagEnd, codTxt, TRUE); // Sharing

  Text outRep = Replace(outTxt, "// FILE    : seed.htm",
                                "// FILE    : "+GetFileName(outFil));

  Text wriFil = If(outFil != "", WriteFile(outFil, outRep), "");
  outTxt
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns the result of full macro expansion in inpFil.
Update the file remmark from classic seed.htm to the output file name outFil.
If outFil is not empty then writes the result in outFil
This version does not use FilWriteIfDiff(), it always update all web site.",
TmeExpandFile);
//////////////////////////////////////////////////////////////////////////////

Text TmeExpandFile() de con-Q.tv

//////////////////////////////////////////////////////////////////////////////
Text TmeExpandFile(Text tagIni, // Initial tag
                   Text tagEnd, // Ending tag
                   Text inpFil, // Input file
                   Text outFil) // Output file
//////////////////////////////////////////////////////////////////////////////
{
  Text codTxt = ReadFile(inpFil);
  Text outTxt = TmeSubMacros(tagIni, tagEnd, codTxt, TRUE); // Sharing

  Text outRep = Replace(outTxt, "// FILE    : seed.htm",
                                "// FILE    : "+GetFileName(outFil));

  Real wriFil = If(outFil != "", FilWriteIfDiff(outFil, outRep), FALSE);
  outTxt
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns the result of full macro expansion in inpFil.
Update the file remmark from classic seed.htm to the output file name outFil.
If outFil is not empty then writes the result in outFil.",
TmeExpandFile);
//////////////////////////////////////////////////////////////////////////////

Text TmeFormat() de Ediciones.aContracorriente

//////////////////////////////////////////////////////////////////////////////
Text TmeFormat(Anything retVal)
//////////////////////////////////////////////////////////////////////////////
{ F(retVal) };
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Intenta retornar un texto a partir de otros tipo, es una funcion equivalente
a la funcion de nombre corto de textos F().",
TmeFormat);
//////////////////////////////////////////////////////////////////////////////

Text TmePst() de con-Q.tv

//////////////////////////////////////////////////////////////////////////////
Text TmePst(Text codTxt) // Other programing language code
//////////////////////////////////////////////////////////////////////////////
{ TmeSubMacros(TmeIni, TmeEnd, codTxt, TRUE) };
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Easy way to call TmeSubMacros() with the default values and behaviour.
Returns the text generated.",
TmePst);
//////////////////////////////////////////////////////////////////////////////

Text TmeSubMacros() de con-Q.tv

//////////////////////////////////////////////////////////////////////////////
Text TmeSubMacros(Text tagIni, // Initial tag
                  Text tagEnd, // Ending tag
                  Text codTxt, // Other programing language code
                  Real share)  // If true share definitions between macros
//////////////////////////////////////////////////////////////////////////////
{
  Set macSet = TmeGetMacros(tagIni, tagEnd, codTxt);
  Set txtSet = If(share, TmeShareMacros(macSet, 1), TmeEvalMacros(macSet));

  Set repTab = For(1, Card(macSet), Set(Real macPos)
               { [[ Text(tagIni+macSet[macPos]+tagEnd), txtSet[macPos] ]] });
  TxtReplaceSecuence(codTxt, repTab) // ReplaceTable(codTxt, repTab, 1)
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns the result of full macro expansion.
The original remmark with the old code ReplaceTable(codTxt, repTab, 1) was:
Be aware if you uses duplicated macros and assumes something about your order
definitions. Now the function TxtReplaceSecuence(codTxt, repTab) make the
replacements in a strick order.
Inside this code always is called with share=TRUE.",
TmeSubMacros);
//////////////////////////////////////////////////////////////////////////////

2015 asolver.com | Aviso legal | XHTML | Δ Θ Ξ | Creative Commons | Mapa y funciones del sitio

Tol