Secciones de la página

fil. tol


Declaraciones


Time oriented language


Árbol de ficheros

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









fil.tol de Ink.Watercolor

File functions.

Declaraciones

Time oriented language

//////////////////////////////////////////////////////////////////////////////
// FILE    : fil.tol
// AUTHOR  : http://www.asolver.com
// PURPOSE : File functions.
//////////////////////////////////////////////////////////////////////////////

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

//////////////////////////////////////////////////////////////////////////////
Real FilDateLT(Text filInp, // Input file
               Text filOut) // Output file
//////////////////////////////////////////////////////////////////////////////
{
  If(Not(FileExist(filInp)), TRUE,
  If(Not(FileExist(filOut)), FALSE,
     FileTime(filInp) < FileTime(filOut)))
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns true if the date of the file filInp is less than the date of the 
file filOut or filInp doesn't exist.
Returns false if the date of the file filInp is great or equal than the date
of the file filOut or filOut does not exist.
This functions lets build makefiles systems.",
FilDateLT);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Text FilKbytes(Text filPth, // Input file
               Text defTxt) // Default text
//////////////////////////////////////////////////////////////////////////////
{
  If(Not(FileExist(filPth)), defTxt,
     FormatReal(FileBytes(filPth)/1024, "%.0lf")+" KBytes")
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns a text expression with the integer size of a file in KBytes.
If the file dows not exist returns the default text defTxt.",
FilKbytes);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Real FilMake(Text filInp, // Input file
             Text filOut, // Output file
             Code makFun) // Real make function with 2 text arguments
//////////////////////////////////////////////////////////////////////////////
{
  If(FilDateLT(filInp, filOut), TRUE,
     makFun(filInp, filOut))
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"If file filInp exist and is newer than file filOut then applies the 2
file arguments makFun to build filOut from filInp and returns the real result
of makFun.
Returns TRUE if filOut is newer than filInp.
Example, makes a jpg file from a tif file:
  Real tinDon = FilMake(clsTif, tinJpg, Real(Text inp, Text out)
                        { AlcImg2JpgDpi(inp, out,  199,  299, 0) });",
FilMake);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Real FilMakeSet(Set  filSet, // Input file
                Code filOut, // Text function to obtain output from input file
                Code makFun) // Real make function with 2 text arguments
//////////////////////////////////////////////////////////////////////////////
{
  Set makCic = EvalSet(filSet, Real(Text filInp)
               { FilMake(filInp, filOut(filInp), makFun) });
  SetSum(makCic)
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Applie FilMake() to a set of files.
The path of the output of each file in filSet is obtained appling filOut()
to the path of each element in filSet.",
FilMakeSet);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Real FilMakeUpdate(Text filInp, // Input file
                   Text filOut, // Output file
                   Code makFun) // Real make function with 2 text arguments
//////////////////////////////////////////////////////////////////////////////
{
  If(Not(FileExist(filOut)), FALSE,
     FilMake(filInp, filOut, makFun))
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"If file filInp exist and is newer than file filOut then applies the 2
file arguments makFun to build filOut from filInp and returns the real result
of makFun.
Returns TRUE if filOut is newer than filInp.
Only works if filOut already exists.
Example, update a zip file if the zip already exists and the jpg is newer than
the zip file:
  Real zipDon = FilMakeUpdate(da4Jpg, da4Zip, ZipAdd);",
FilMakeUpdate);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Real FilOccurrences(Text filPth, // Input file path
                    Text txtPat) // Pattern
//////////////////////////////////////////////////////////////////////////////
{
  If(Not(FileExist(filPth)), 0,
  {
    Text filTxt = ReadFile(filPth);
    TextOccurrences(filTxt, txtPat)
  })
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns the number of occurrences of the searched text txtPat within a 
file filPth.
If the file filPth does not exist then returns 0.",
FilOccurrences);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Real FilSplit(Text inpFil, // File name
              Real overWr, // If true overwrite the output files
              Code filOut) // Function that returns files paths
//////////////////////////////////////////////////////////////////////////////
{
  Set  ctrSet = Copy(Empty); // Output file control

  // Open as Bdb
  Set  inpBdb = BDBOpen(inpFil,Copy(FALSE),"\n","","");
  Real maxReg = inpBdb->RegNumber;

  // Procesar desde iniOk hasta endOk
  Real numReg = 1;
  Real While(LE(numReg,maxReg),
  {
    Text inpLin = BDBReg(inpBdb, numReg)[1]; // Read a line
    Text outFil = filOut(inpLin);
    Real chkOve = If(Not(overWr), FALSE, // Not overwrite
    {
      Real ctrPos = SetTxtFindFirst(ctrSet, outFil, FALSE);
      Real notNew = If(GT(ctrPos,0), TRUE, // Already writed,
      {
        Set(ctrSet:=ctrSet<<[[Copy(outFil)]]); // Insert the file path
        Text WriteFile(outFil,"");             // Overwrite
        FALSE
      })
    });

    Text AppendFile(outFil,inpLin+"\n");     // La agrega al final
    Real(numReg:=numReg+1);
    TRUE
  });

  Real BDBClose(inpBdb);

  numReg
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Split a file (inpFil) y several files and returns the number of lines
processed.
This function applies the argument function filOut() to each line of the file,
filOut() function must return a output file path where the line will be
append.
If the argument overWr is false this function only append lines (not
overwrite) to output files.
If the argument overWr is true this function overwrite the output files before
the first append.
An example of use in ApaSplitFile() function.",
FilSplit);
//////////////////////////////////////////////////////////////////////////////

Árbol de ficheros

Ink.Watercolor construye las páginas del sitio web inkwatercolor.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
      • set.tol funciones de manejo de conjuntos
      • tab.tol funciones de tablas como set of sets
      • ser.tol funciones de series temporales
      • fil.tol funciones de gestión de ficheros
      • zip.tol compresor de ficheros en línea de mandatos
      • apa.tol proceso de ficheros de log de Apache
      • dir.tol funciones de gestión de directorios
    • app funciones especificas de Ink.Watercolor
      • pdb.tol funciones de la base de datos de pinturas
      • pag.tol funciones para generar páginas web Html
      • sed.tol semillas, templates, de páginas web Html
      • ftp.tol funciones para generar mandatos para hacer Ftp
      • xml.tol funciones históricas para sitemaps en Xml
      • alc.tol alchemy para la transformación de imágenes
      • ink.tol funciones auxiliares de InkWatercolor
    • 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
    • chpphodb01.txt ejemplo con las 4 primeras obras artísticas que se incluyeron
  • web directorio destinado a las paginas web generadas automáticamente
    • common directorio de recursos comunes a todas las galerías
      • css directorio para ficheros de estilo
        • common.css fichero de estilo para las paginas Html del sitio web
      • seed trozos de código Html para construir templates
        • strseed.htm estructura básica de página Html de inkwatercolor.com
        • pi1lowseed.htm estructura para albergar información sobre una obra
        • pi4cntseed.htm estructura para albergar 4 pinturas en una página
      • src directorio para ficheros javascript
    • chppho directorio para la galería principal de Inkwatercolor
      • index.html ejemplo de página Html generada automáticamente
    • download directorio para material extra para descargas
      • chppho0129.jpg ejemplo de imagen de obra artística para descargar
      • chppho0143.jpg ejemplo de imagen de obra artística para descargar
    • sitemap.xml mapa del sitio web generado en Xml de forma automática
  • history archivo de registro histórico del programa Ink.Watercolor
  • ink_watercolor.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