Secciones de la página

pdb. tol


Declaraciones


Constantes


Funciones


Time oriented language


Árbol de ficheros

Funciones

Set PdbRead()

Set PdbFirstN()

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









pdb.tol de Ediciones.aContracorriente

Posts database functions.

Declaraciones

Constantes

  • Text PdbSep
    Post separator inside the agendas.

Funciones

  • Set PdbRead(Text inpDir)
    Reads and returns a post database.
  • Set PdbFirstN(Set inpSet, Real maxNum, Code funSel)
    Returns the maxNum recents posts for funSel.

Constantes

Text PdbSep

//////////////////////////////////////////////////////////////////////////////
Text PdbSep = Repeat("_",78);
//////////////////////////////////////////////////////////////////////////////
PutDescription("Post separator inside the agendas.", PdbSep);
//////////////////////////////////////////////////////////////////////////////

Funciones

Set PdbRead()

//////////////////////////////////////////////////////////////////////////////
Set PdbRead(Text inpDir)
//////////////////////////////////////////////////////////////////////////////
{
  Real err(Text msg){ Text WriteLn("\nERROR: "+msg+"\n"); FALSE }; // Function
  
  Text filSep = Char(7); // Bell character

  Text WriteLn("Reading "+inpDir+"...");
  Text inpAll = DirReadFiles(inpDir, "age", filSep);

  Text inpTxt = Replace(inpAll, PdbSep+"\n",filSep);
  Set  inpSet = Tokenizer(inpTxt,filSep);

  Set  inpTab = EvalSet(inpSet, Set(Text inf)
  {
    // Read each field
    Set  pstCla = 
    {
      Text claTxt = TxtBetween2Tag(inf,"<Pst.Cla>","\n<Pst.",TRUE);
      Set  claSet = Txt2Set(claTxt, ";");

      Case( // Categoria de completo para los que han de salir en completo
        Card(claSet * CatBuy), claSet, // Hay interseccion con la tienda
        "Buscar" <: claSet,    claSet, // Es de busqueda
        TRUE,                  claSet <<
                               [["Completo"]]) // Post normal a completo
    };

    Text pstSta =                                            // C por defecto
      Sub(         TxtBetween2Tag(inf,"<Pst.Sta>", "\n<Pst.", TRUE)+"C",1,1);

    Text pstCod =  TxtBetween2Tag(inf,"<Pst.Cod>", "\n<Pst.", TRUE);

    Text pstRed = 
      PhtRedTitle( TxtBetween2Tag(inf,"<Pst.Tit>", "\n<Pst.", TRUE));

    Text pstTit =  TxtOutHtmScr(pstRed);

    Date pstDte =
      Eval(        TxtBetween2Tag(inf,"<Pst.Dte>", "\n<Pst.", TRUE));

    Text pstTyp =  TxtBetween2Tag(inf,"<Pst.Typ>", "\n<Pst.", TRUE);

    Text pstAut =  TxtBetween2Tag(inf,"<Pst.Aut>", "\n<Pst.", TRUE);

    Text pstHtm = 
      PhtRedText(  TxtBetween2Tag(inf,"<Pst.Txt>", "\n<Pst.", FALSE));

    Text pstTxt =  TxtOutHtmScr(pstHtm);

    Text pstLnk =
      PhtRedText(  TxtBetween2Tag(inf,"<Pst.Lnk>", "\n<Pst.", FALSE));

    Text pstPay =  TxtBetween2Tag(inf,"<Pst.Pay>", "\n<Pst.", FALSE);

    Text pstRem =  TxtBetween2Tag(inf,"<Pst.Rem>", "\n<Pst.", FALSE);

    // Check valid end <Pst.End> not old end <End>
    Real chkEnd = If(TextFind(inf,"<Pst.End>"), TRUE,
                     err("Not <Pst.End> at: "+pstCod));

    // Check that all categories are valid
    Set  chkCla = EvalSet(pstCla, Real(Text claNam) // Category class
    { If(claNam <: CatAll, TRUE, err("Class: "+pstCod+" "+claNam)) });

    // Build a Pdb object and returns it
    PdbSt(pstCla, pstSta, pstCod, pstRed, pstTit, pstDte, pstTyp,
          pstAut, pstHtm, pstTxt, pstLnk, pstPay, pstRem)
  });

  // Seleccionar los post no anulado
  Set inpSel = Select(inpTab, Real(Set a) { a->pstSta != "A" }); // No Anulado

  // Ordenar por el codigo (clave) del post
  Set inpSor = Sort(inpSel, Real(Set a, Set b) // By code
               { Compare(a->pstCod, b->pstCod) });
 
  Real chkDup = // Check duplicated posts, with the same code
  {
    Set codCla = Classify(inpTab, Real(Set a, Set b) // By code
                 { Compare(a->pstCod,b->pstCod) });
    Set codDup = EvalSet(codCla, Real(Set cla)
    {
      Real crd = Card(cla);
      Text nam = cla[1]->pstCod;
      If(EQ(crd,1), TRUE,
         err("Name: "+nam+" "+FormatReal(crd,"%.0lf")+" times"))
    });
    
    // Los titulos han de ser diferentes para que los ficheros sean diferentes
    Set pthCla = Classify(inpTab, Real(Set a, Set b) // By external path/Title
    {
      Compare(PhtFileName(TxtOutside2Tag(a->pstTit, "<", ">")),
              PhtFileName(TxtOutside2Tag(b->pstTit, "<", ">")))
    });

    Set pthDup = EvalSet(pthCla, Real(Set cla)
    {
      Real crd = Card(cla);
      Text pth = cla[1]->pstCod;
      If(EQ(crd,1), TRUE,
         err("Similar titles:\n  ["+cla[1]->pstTit+
                           "]\n  ["+cla[2]->pstTit+"]"))
    });
    Card(codDup)+Card(pthDup)
  };
  
  Text WriteLn("Status ABCD "+FormatReal(Card(inpTab),"%3.0lf")+" registers");
  Text WriteLn("Status _BCD "+FormatReal(Card(inpSel),"%3.0lf")+" registers");

  inpSor
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Reads and returns a post database.",
PdbRead);
//////////////////////////////////////////////////////////////////////////////

Set PdbFirstN()

//////////////////////////////////////////////////////////////////////////////
Set PdbFirstN(Set  inpSet, // Post database
              Real maxNum, // Maximum numbers of posts to return
              Code funSel) // Post selection conditions
//////////////////////////////////////////////////////////////////////////////
{
  Set  selFst = Select(inpSet, funSel); // Select all that funSel()
  SetFirstN(selFst, maxNum)             // Fst maxNum or all if there are few
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns the maxNum recents posts for funSel.",
PdbFirstN);
//////////////////////////////////////////////////////////////////////////////

Time oriented language

//////////////////////////////////////////////////////////////////////////////
// FILE    : pdb.tol
// AUTHOR  : http://www.asolver.com
// PURPOSE : Posts database functions.
//////////////////////////////////////////////////////////////////////////////


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

//////////////////////////////////////////////////////////////////////////////
Text PdbSep = Repeat("_",78);
//////////////////////////////////////////////////////////////////////////////
PutDescription("Post separator inside the agendas.", PdbSep);
//////////////////////////////////////////////////////////////////////////////


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

//////////////////////////////////////////////////////////////////////////////
Set PdbRead(Text inpDir)
//////////////////////////////////////////////////////////////////////////////
{
  Real err(Text msg){ Text WriteLn("\nERROR: "+msg+"\n"); FALSE }; // Function
  
  Text filSep = Char(7); // Bell character

  Text WriteLn("Reading "+inpDir+"...");
  Text inpAll = DirReadFiles(inpDir, "age", filSep);

  Text inpTxt = Replace(inpAll, PdbSep+"\n",filSep);
  Set  inpSet = Tokenizer(inpTxt,filSep);

  Set  inpTab = EvalSet(inpSet, Set(Text inf)
  {
    // Read each field
    Set  pstCla = 
    {
      Text claTxt = TxtBetween2Tag(inf,"<Pst.Cla>","\n<Pst.",TRUE);
      Set  claSet = Txt2Set(claTxt, ";");

      Case( // Categoria de completo para los que han de salir en completo
        Card(claSet * CatBuy), claSet, // Hay interseccion con la tienda
        "Buscar" <: claSet,    claSet, // Es de busqueda
        TRUE,                  claSet <<
                               [["Completo"]]) // Post normal a completo
    };

    Text pstSta =                                            // C por defecto
      Sub(         TxtBetween2Tag(inf,"<Pst.Sta>", "\n<Pst.", TRUE)+"C",1,1);

    Text pstCod =  TxtBetween2Tag(inf,"<Pst.Cod>", "\n<Pst.", TRUE);

    Text pstRed = 
      PhtRedTitle( TxtBetween2Tag(inf,"<Pst.Tit>", "\n<Pst.", TRUE));

    Text pstTit =  TxtOutHtmScr(pstRed);

    Date pstDte =
      Eval(        TxtBetween2Tag(inf,"<Pst.Dte>", "\n<Pst.", TRUE));

    Text pstTyp =  TxtBetween2Tag(inf,"<Pst.Typ>", "\n<Pst.", TRUE);

    Text pstAut =  TxtBetween2Tag(inf,"<Pst.Aut>", "\n<Pst.", TRUE);

    Text pstHtm = 
      PhtRedText(  TxtBetween2Tag(inf,"<Pst.Txt>", "\n<Pst.", FALSE));

    Text pstTxt =  TxtOutHtmScr(pstHtm);

    Text pstLnk =
      PhtRedText(  TxtBetween2Tag(inf,"<Pst.Lnk>", "\n<Pst.", FALSE));

    Text pstPay =  TxtBetween2Tag(inf,"<Pst.Pay>", "\n<Pst.", FALSE);

    Text pstRem =  TxtBetween2Tag(inf,"<Pst.Rem>", "\n<Pst.", FALSE);

    // Check valid end <Pst.End> not old end <End>
    Real chkEnd = If(TextFind(inf,"<Pst.End>"), TRUE,
                     err("Not <Pst.End> at: "+pstCod));

    // Check that all categories are valid
    Set  chkCla = EvalSet(pstCla, Real(Text claNam) // Category class
    { If(claNam <: CatAll, TRUE, err("Class: "+pstCod+" "+claNam)) });

    // Build a Pdb object and returns it
    PdbSt(pstCla, pstSta, pstCod, pstRed, pstTit, pstDte, pstTyp,
          pstAut, pstHtm, pstTxt, pstLnk, pstPay, pstRem)
  });

  // Seleccionar los post no anulado
  Set inpSel = Select(inpTab, Real(Set a) { a->pstSta != "A" }); // No Anulado

  // Ordenar por el codigo (clave) del post
  Set inpSor = Sort(inpSel, Real(Set a, Set b) // By code
               { Compare(a->pstCod, b->pstCod) });
 
  Real chkDup = // Check duplicated posts, with the same code
  {
    Set codCla = Classify(inpTab, Real(Set a, Set b) // By code
                 { Compare(a->pstCod,b->pstCod) });
    Set codDup = EvalSet(codCla, Real(Set cla)
    {
      Real crd = Card(cla);
      Text nam = cla[1]->pstCod;
      If(EQ(crd,1), TRUE,
         err("Name: "+nam+" "+FormatReal(crd,"%.0lf")+" times"))
    });
    
    // Los titulos han de ser diferentes para que los ficheros sean diferentes
    Set pthCla = Classify(inpTab, Real(Set a, Set b) // By external path/Title
    {
      Compare(PhtFileName(TxtOutside2Tag(a->pstTit, "<", ">")),
              PhtFileName(TxtOutside2Tag(b->pstTit, "<", ">")))
    });

    Set pthDup = EvalSet(pthCla, Real(Set cla)
    {
      Real crd = Card(cla);
      Text pth = cla[1]->pstCod;
      If(EQ(crd,1), TRUE,
         err("Similar titles:\n  ["+cla[1]->pstTit+
                           "]\n  ["+cla[2]->pstTit+"]"))
    });
    Card(codDup)+Card(pthDup)
  };
  
  Text WriteLn("Status ABCD "+FormatReal(Card(inpTab),"%3.0lf")+" registers");
  Text WriteLn("Status _BCD "+FormatReal(Card(inpSel),"%3.0lf")+" registers");

  inpSor
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Reads and returns a post database.",
PdbRead);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Set PdbFirstN(Set  inpSet, // Post database
              Real maxNum, // Maximum numbers of posts to return
              Code funSel) // Post selection conditions
//////////////////////////////////////////////////////////////////////////////
{
  Set  selFst = Select(inpSet, funSel); // Select all that funSel()
  SetFirstN(selFst, maxNum)             // Fst maxNum or all if there are few
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns the maxNum recents posts for funSel.",
PdbFirstN);
//////////////////////////////////////////////////////////////////////////////

Árbol de ficheros

Ediciones.aContracorriente construye las páginas del sitio web edicionesacontracorriente.com

  • make.tol proceso principal de generación de contenidos del sitio web
  • tol directorios de código fuente en lenguaje de programación Tol
    • cmm funciones comunes de textos, fechas, conjuntos, ficheros, etc.
      • txt.tol funciones de manejo de textos
      • dte.tol funciones de manejo de fechas en español
      • set.tol funciones de manejo de conjuntos
      • fil.tol funciones de gestión de ficheros
      • dir.tol funciones de gestión de directorios
      • tme.tol del macro-expansor simple de Tol en Html
      • htm.tol funciones básicas del lenguaje Html
      • ftp.tol funciones para generar mandatos para hacer Ftp
      • xsm.tol para construir sitemaps en Xml
    • app funciones específicas de Ediciones.aContracorriente
      • pdb.tol funciones de manejo de los posts de una agenda
      • pht.tol funciones auxiliares para el Html de los post
    • inc.tol inclusión de los ficheros Tol básicos y de aplicación
  • agenda directorio destinado a albergar los ficheros de agendas de posts
  • web directorio destinado a las páginas web generadas automáticamente
    • css directorio para ficheros de estilo
      • common.css fichero de estilo para las páginas Html del sitio web
    • src directorio para ficheros javascript
      • ads.js código Javascript para emitir anuncios desde otros sitios
      • txt.js código Javascript para el manejo de textos
    • articulos directorio para páginas de artículos generadas por este programa
    • categorias directorio para páginas de categorias generadas automáticamente
    • sitemap.xml mapa del sitio web generado en Xml de forma automática
  • history archivo histórico del programa Ediciones.aContracorriente
  • ediciones_acontracorriente.pdf documento resumen de funciones del programa de generación Html

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

Tol