Secciones de la página

tme. tol


Declaraciones


Constantes


Funciones


Time oriented language


Árbol de ficheros

Funciones

Set TmeGetMacros()

Text TmeFormat()

Set TmeEvalMacros()

Set TmeShareMacros()

Text TmeSubMacros()

Text TmePst()

Text TmeExpandFile()

Real TmeFile()

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









tme.tol de con-Q.tv

Macro-expansor potenciado de Tol para ser inyectado en Html o en otros lenguajes de programacion.

Por defecto utiliza tags que combinan < y { el inicial y el final } y > como Php utiliza <? y ?> y Asp <% y %>.

Esta es la version potenciada que permite inyectar Tol dentro de semillas Html del tipo seed.htm, este codigo Tol embebido se expande en el codigo Html de las agendas de post u otras cosas, que a su vez pueden contener codigo Tol embebido que se puede volver a expandir. Existe una version de este codigo que no admite esta capacidad.

Esta es una version especialmente depurada de este codigo e incluye la modificacion TxtReplaceSecuence(codTxt, repTab) en vez de la clasica ReplaceTable(codTxt, repTab, 1).

Declaraciones

Constantes

  • Text TmeIni
    Default initial tag. Other tags can be used as <% like Asp or <? like Php.
  • Text TmeEnd
    Default ending tag. Other tags can be used as %> like Asp or ?> like Php.
  • Text TmeSep
    For internal use. Lets use Tokenizer() replacing initial tags by TmeSep.
  • Text TmeEmpty
    All code must return some text. If there are only definitions and replace with nothing can be ended with an empty string of with a TmeEmpty.

Funciones

  • Set TmeGetMacros(Text tagIni, Text tagEnd, Text codTxt)
    Returns a set with all codes inside the initial en the ending tags.
  • Text TmeFormat(Anything retVal)
    Intenta retornar un texto a partir de otros tipo, es una funcion equivalente a la funcion de nombre corto de textos F().
  • Set TmeEvalMacros(Set codSet)
    Returns a set with the text results of all macros. This secuential evaluation does not let to share functions and variables between macros.
  • Set TmeShareMacros(Set codSet, Real codPos)
    Returns a set with the text results of all macros. This recursive evaluation lets to share definitions, functions and variables between macros.
  • Text TmeSubMacros(Text tagIni, Text tagEnd, Text codTxt, Real share)
    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.
  • Text TmePst(Text codTxt)
    Easy way to call TmeSubMacros() with the default values and behaviour. Returns the text generated.
  • Text TmeExpandFile(Text tagIni, Text tagEnd, Text inpFil, Text outFil)
    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.
  • Real TmeFile(Text inpFil, Text outFil)
    Easy way to call TmeExpandFile() with the default values and behaviour. Returns true if some text was generated.

Constantes

Text TmeIni

//////////////////////////////////////////////////////////////////////////////
Text TmeIni = "<"+"{";
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Default initial tag. Other tags can be used as <% like Asp or <? like Php.",
TmeIni);
//////////////////////////////////////////////////////////////////////////////

Text TmeEnd

//////////////////////////////////////////////////////////////////////////////
Text TmeEnd = "}"+">";
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Default ending tag. Other tags can be used as %> like Asp or ?> like Php.",
TmeIni);
//////////////////////////////////////////////////////////////////////////////

Text TmeSep

//////////////////////////////////////////////////////////////////////////////
Text TmeSep = Char(7);
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"For internal use. Lets use Tokenizer() replacing initial tags by TmeSep.",
TmeIni);
//////////////////////////////////////////////////////////////////////////////

Text TmeEmpty

//////////////////////////////////////////////////////////////////////////////
Text TmeEmpty = "";
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"All code must return some text. If there are only definitions and replace
with nothing can be ended with an empty string of with a TmeEmpty.",
TmeEmpty);
//////////////////////////////////////////////////////////////////////////////

Funciones

Set TmeGetMacros()

//////////////////////////////////////////////////////////////////////////////
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);
//////////////////////////////////////////////////////////////////////////////

Text TmeFormat()

//////////////////////////////////////////////////////////////////////////////
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);
//////////////////////////////////////////////////////////////////////////////

Set TmeEvalMacros()

//////////////////////////////////////////////////////////////////////////////
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 TmeShareMacros()

//////////////////////////////////////////////////////////////////////////////
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 TmeSubMacros()

//////////////////////////////////////////////////////////////////////////////
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);
//////////////////////////////////////////////////////////////////////////////

Text TmePst()

//////////////////////////////////////////////////////////////////////////////
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 TmeExpandFile()

//////////////////////////////////////////////////////////////////////////////
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);
//////////////////////////////////////////////////////////////////////////////

Real TmeFile()

//////////////////////////////////////////////////////////////////////////////
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);
//////////////////////////////////////////////////////////////////////////////

Time oriented language

//////////////////////////////////////////////////////////////////////////////
// FILE    : tme.tol
// AUTHOR  : http://www.asolver.com
// PURPOSE : Macro-expansor potenciado de Tol para ser inyectado en Html o en
// otros  lenguajes de programacion.
// _
// Por defecto utiliza tags que combinan < y { el inicial y el final } y >
// como Php utiliza <? y ?> y Asp <% y %>.
// _
// Esta es la version potenciada que permite inyectar Tol dentro de semillas
// Html del tipo seed.htm, este codigo Tol embebido se expande en el codigo
// Html de las agendas de post u otras cosas, que a su vez pueden contener
// codigo Tol embebido que se puede volver a expandir. Existe una version de
// este codigo que no admite esta capacidad.
// _
// Esta es una version especialmente depurada de este codigo e incluye la
// modificacion TxtReplaceSecuence(codTxt, repTab) en vez de la clasica
// ReplaceTable(codTxt, repTab, 1).
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
// CONSTANTS
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
Text TmeIni = "<"+"{";
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Default initial tag. Other tags can be used as <% like Asp or <? like Php.",
TmeIni);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Text TmeEnd = "}"+">";
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Default ending tag. Other tags can be used as %> like Asp or ?> like Php.",
TmeIni);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Text TmeSep = Char(7);
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"For internal use. Lets use Tokenizer() replacing initial tags by TmeSep.",
TmeIni);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Text TmeEmpty = "";
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"All code must return some text. If there are only definitions and replace
with nothing can be ended with an empty string of with a TmeEmpty.",
TmeEmpty);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
// FUNCTIONS
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
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);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
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);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
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 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 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);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
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 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);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
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);
//////////////////////////////////////////////////////////////////////////////

Árbol de ficheros

con-Q.tv construye las páginas del sitio y newsletter Con-Q.tv

  • make.tol proceso principal de generacion del sitio web y la newsletter
  • tol directorios de código Tol
    • cmm funciones comunes
      • txt.tol funciones de textos
      • set.tol funciones de conjuntos
      • fil.tol funciones de ficheros
      • dir.tol funciones directorios
      • tme.tol funciones del macro-expansor de Tol en Html
      • img.tol funciones de imagenes Html
      • ftp.tol para generar mandatos para hacer Ftp
      • xsm.tol para construir sitemaps en Xml
    • app funciones especificas de aplicacion
      • ads.tol funciones de anuncios de publicidad
      • pdb.tol funciones de manejo de los posts de una agenda
      • pht.tol funciones auxiliares para el Html de los post
    • inc.tol para la inclusión de ficheros Tol
  • agenda directorio destinado a la agenda de post
  • web directorio destinado a las páginas web generadas
    • css directorio para ficheros de estilo
      • common.css fichero de estilo Css para las páginas Html
    • seed directorio para ficheros semilla
      • seed.htm semilla de página Html con Tol embebido
      • lopd.htm texto Lopd para insertar en la newsletter de envío por email
    • src directorio para ficheros con código Javascript
      • common.js funciones Javascript para diferentes redes sociales
    • noticia directorio para páginas de noticias
    • quiosco directorio para páginas Html de categorias
      • asamblea.html ejemplo de página de categoría generada automáticamente
    • sitemap.xml mapa completo del sitio web generado en Xml automáticamente
  • presentacion.html vídeo de presentación de la Newsletter de la Avppm
  • con-q_tv.pdf documento resumen de funciones del programa de la newsletter

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

Tol