Pictures database functions. Attributes: Pic.Cla) La clase a la que pertenece la obra de arte, este atributo debería ser coincidente con la galería. Pic.Ser) La serie, dentro de la clase anterior, a la que pertenece la obra. Pic.Wid) El ancho de la pintura en milímetros. Pic.Hei) El alto de la pintura en milímetros. End.Dte) Fecha de terminación del cuadro especificada en lenguaje TOL. Upd.Dte) Fecha de última actualización de los datos de registro del cuadro, fecha que se especificada en TOL. Pic.Num) Número único de identificación del cuadro dentro de su galería, este número actua como clave única de la obra dentro de su galería y es el que se usa para dar nombre a sus páginas web y crear los enlaces entre las diferentes obras de arte. Pic.Tit) Título del cuadro que puede especificarse en inglés y en castellano como { English | Castellano } y que puede contener partes relevantes o principales y accesorias como { rest (main) | resto (principal) }. Wrk.Tim) Número de horas de trabajo empleadas por el artista para completar su obra. Wrk.Qly) Indicador de calidad de la obra, pudiendo emplearse ?, el desconocido en TOL, para aquellas obras no calificadas o pendientes de calificación. Pap.Tec) Técnica de fabricación del soporte, por ejemplo, del papel. Pap.Col) Color o colores de fabricación del soporte, por ejemplo, el color del papel, si son varios colores se separar por punto y coma. Bck.Tec) Técnicas y materiales empleados para crear la base de la obra artística. Bck.Col) Color o colores empleados para crear la base de la obra artística, si son varios colores se separan por punto y coma, por ejemplo, orange; yellow. For.Tec) Técnicas y materiales empleado para crear la obra artística. For.Col) Color o colores empleados para crear la obra artística, si hay más de un color se separan por punto y coma y si es un solo color no se emplea el punto y coma, por ejemplo, black. Pic.Aut) Nombre completo del artista autor de la obra. Pic.Own) Nombre del titular propietario actual de la obra, ya sea persona física o jurídica, o el nombre del último titular conocido o un texto genérico de pertenencia a una colección. Pic.Prn) Número de reproducciones de la obra artística. Pic.Rem) Comentarios que pueden ser en inglés y en castellano y que, a diferencia de los comentarios de las agendas de otros sitios web, si se publican.
Constantes
Text PdbSepFunciones
Set PdbRead(Text inpFil, Set inpBst)Set PdbRenum(Set inpSet)Set PdbLastUpdates(Set inpSet, Real maxNum)Real PdbRenamePic(Set picSet, Text dirPth)Real PdbInit(Text outFil, Real maxPic)//////////////////////////////////////////////////////////////////////////////
Text PdbSep = Repeat("_",78);
//////////////////////////////////////////////////////////////////////////////
PutDescription("Horizontal line between registers.", PdbSep);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Set PdbRead(Text inpFil, Set inpBst)
//////////////////////////////////////////////////////////////////////////////
{
Text WriteLn("Reading "+inpFil+"...");
Text inpTxt = Replace(ReadFile(inpFil),PdbSep+"\n","·");
Set inpSet = Tokenizer(inpTxt,"·");
Set inpTab = EvalSet(inpSet, Set(Text inf)
{
Text picCla = TxtBetween2Tag(inf,"<Pic.Cla>", "\n<", TRUE);
Text picSer = TxtBetween2Tag(inf,"<Pic.Ser>", "\n<", TRUE);
Real picWid = Eval(TxtBetween2Tag(inf,"<Pic.Wid>", "\n<", TRUE));
Real picHei = Eval(TxtBetween2Tag(inf,"<Pic.Hei>", "\n<", TRUE));
Date endDte = Eval(TxtBetween2Tag(inf,"<End.Dte>", "\n<", TRUE));
Date updDte = Eval(TxtBetween2Tag(inf,"<Upd.Dte>", "\n<", TRUE));
Text picTxt = TxtBetween2Tag(inf,"<Pic.Num>", "\n<", TRUE);
Real picNum = Eval(picTxt);
Text picTit = TxtBetween2Tag(inf,"<Pic.Tit>", "\n<", TRUE);
Real wrkTim = Eval(TxtBetween2Tag(inf,"<Wrk.Tim>", "\n<", TRUE));
Real wrkQly = Eval(TxtBetween2Tag(inf,"<Wrk.Qly>", "\n<", TRUE));
Set papTec = Txt2Set(TxtBetween2Tag(inf,"<Pap.Tec>", "\n<", TRUE), Empty, TRUE);
Set papCol = Txt2Set(TxtBetween2Tag(inf,"<Pap.Col>", "\n<", TRUE), Empty, TRUE);
Set bckTec = Txt2Set(TxtBetween2Tag(inf,"<Bck.Tec>", "\n<", TRUE), Empty, TRUE);
Set bckCol = Txt2Set(TxtBetween2Tag(inf,"<Bck.Col>", "\n<", TRUE), Empty, TRUE);
Set forTec = Txt2Set(TxtBetween2Tag(inf,"<For.Tec>", "\n<", TRUE), Empty, TRUE);
Set forCol = Txt2Set(TxtBetween2Tag(inf,"<For.Col>", "\n<", TRUE), Empty, TRUE);
Text picAut = TxtBetween2Tag(inf,"<Pic.Aut>", "\n<", TRUE);
Text picOwn = TxtBetween2Tag(inf,"<Pic.Own>", "\n<", TRUE);
Text jpgFil = PagGal+PagNumInt(picNum, TRUE)+".jpg";
Set picSel = Select(inpBst, Real(Set a) { a[1]==picTxt });
Real picPrn = If(EQ(Card(picSel),1), picSel[1][2], 0);
Text picRem = TxtBetween2Tag(inf,"<Pic.Rem>", "\n<", TRUE);
PdbSt(picCla,picSer,picWid,picHei,endDte,updDte,picNum,picTit,
wrkTim,wrkQly,
papTec,papCol,bckTec,bckCol,forTec,forCol,
picAut,picOwn,jpgFil,picPrn,picRem)
});
Set inpSor = Sort(inpTab, Real(Set a, Set b)
{ Compare(a->picNum,b->picNum) });
Text WriteLn("Readed "+FormatReal(Card(inpSor),"%.0lf")+" registers");
inpSor
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Reads and returns a pictures database.",
PdbRead);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Set PdbRenum(Set inpSet)
//////////////////////////////////////////////////////////////////////////////
{
Text WriteLn("Renumering database...");
For(1, Card(inpSet), Set(Real pos)
{
Set reg = inpSet[pos];
PdbSt(reg->picCla,
reg->picSer,
reg->picWid,
reg->picHei,
reg->endDte,
reg->updDte,
pos, // Change picNum for the position
reg->picTit,
reg->wrkTim,
reg->wrkQly,
reg->papTec,
reg->papCol,
reg->bckTec,
reg->bckCol,
reg->forTec,
reg->forCol,
reg->picAut,
reg->picOwn,
reg->jpgFil,
reg->picPrn,
reg->picRem)
})
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns a pictures database where the picNum is the position.",
PdbRenum);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Set PdbLastUpdates(Set inpSet,
Real maxNum)
//////////////////////////////////////////////////////////////////////////////
{
Text WriteLn("Last updates...");
Set selLst = SetFirstNByFun(inpPdb, maxNum, Real(Set a, Set b)
{ Compare(b->updDte,a->updDte) }); // Descending
Set sorLst = Sort(selLst, Real(Set a, Set b)
{ Compare(a->endDte,b->endDte) }); // Ascending
PdbRenum(sorLst) // Renumering
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns the last updates.",
PdbLastUpdates);
//////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
Real Pag2CtrCsv(Set inpPdb) // Pictures database
//////////////////////////////////////////////////////////////////////////////
{
Text imgCsv = "ctr/img.csv"; // Control de visualizaciones en Excel
Text WriteFile(imgCsv,"");
Set cicSet = For(1, maxReg, Real(Real numReg)
{
Set picReg = inpPdb[numReg];
Text AppendFile(imgCsv, FormatReal(picReg->picNum,"%.0lf")+";"+
Replace(picReg->picTit,";"," |")+";"+
dteTxt+";"+
FormatReal(picReg->picPrn,"%.0lf")+";\n");
TRUE
});
Card(cicSet)
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Writes a Csv file in control directory (ctr) with the number, title and
the number of visualizations for statistics.",
Pag2CtrCsv);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Real PdbRenamePic(Set picSet, Text dirPth)
//////////////////////////////////////////////////////////////////////////////
{
Set filSet = GetDir(dirPth)[1];
Set renSet = For(1, Card(picSet), Real(Real picNum)
{
Set picReg = picSet[picNum];
Text filNew = picReg->jpgFil;
Text filOld = filSet[picNum];
FileRename(dirPth+"/"+filOld, dirPth+"/"+filNew)
});
Card(renSet)
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Not useful now.",
PdbRenamePic);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Real PdbInit(Text outFil, Real maxPic)
//////////////////////////////////////////////////////////////////////////////
{
Text txtSee =
"<Pic.Cla> Chp\n"+
"<Pic.Ser> Pho\n"+
"<Pic.Wid> 310\n"+
"<Pic.Hei> 460\n"+
"<End.Dte> y1999m11d30\n"+
"<Upd.Dte> _UPD_\n"+
"<Pic.Num> _NUM_\n"+
"<Pic.Tit> title\n"+
"<Wrk.Tim> 8\n"+
"<Wrk.Qly> 1.00\n"+
"<Pap.Tec> Fabriano paper\n"+
"<Pap.Col> \n"+
"<Bck.Tec> watercolor\n"+
"<Bck.Col> orange\n"+
"<For.Tec> ink\n"+
"<For.Col> black\n"+
"<Pic.Aut> Antonio Salmeron\n"+
"<Pic.Own> Antonio Salmeron\n"+
"<Jpg.Fil> cphpho_NUM_.jpg\n"+
"<Pic.Prn> _PRN_\n"+
"<Pic.Rem> \n"+
"<End>\n";
If(FileExist(outFil), { WriteLn(outFil+" already exists"); 0 },
{
Text WriteFile(outFil, "");
Set wriSet = For(1, maxPic, Real(Real numPic)
{
Date updDte = Succ(y2002m01d01, C, Round(Rand(3,200)));
Text updTxt = FormatDate(updDte,"%cy%Ym%md%d");
Text numTxt = FormatReal(numPic, "%04.0lf");
Text prnTxt = FormatReal(Rand(0,50), "%.0lf");
Text regTxt = ReplaceTable(txtSee,
[[ [["_NUM_", numTxt]],
[["_UPD_", updTxt]],
[["_PRN_", prnTxt]] ]]);
Text regSep = If(EQ(numPic,maxPic), "", PdbSep);
Text AppendFile(outFil, regTxt+regSep+"\n");
TRUE
});
Card(wriSet)
})
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Not used now. This function creates an initial pictures databse.",
PdbInit);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// FILE : pdb.tol
// AUTHOR : http://www.asolver.com
// PURPOSE : Pictures database functions.
// Attributes:
// Pic.Cla) La clase a la que pertenece la obra de arte,
// este atributo debería ser coincidente con la galería.
// Pic.Ser) La serie, dentro de la clase anterior, a la que pertenece la obra.
// Pic.Wid) El ancho de la pintura en milímetros.
// Pic.Hei) El alto de la pintura en milímetros.
// End.Dte) Fecha de terminación del cuadro especificada en lenguaje TOL.
// Upd.Dte) Fecha de última actualización de los datos de registro del cuadro,
// fecha que se especificada en TOL.
// Pic.Num) Número único de identificación del cuadro dentro de su galería,
// este número actua como clave única de la obra dentro de su galería
// y es el que se usa para dar nombre a sus páginas web y crear los
// enlaces entre las diferentes obras de arte.
// Pic.Tit) Título del cuadro que puede especificarse
// en inglés y en castellano como { English | Castellano } y que
// puede contener partes relevantes o principales y accesorias como
// { rest (main) | resto (principal) }.
// Wrk.Tim) Número de horas de trabajo empleadas por el artista
// para completar su obra.
// Wrk.Qly) Indicador de calidad de la obra,
// pudiendo emplearse ?, el desconocido en TOL,
// para aquellas obras no calificadas o pendientes de calificación.
// Pap.Tec) Técnica de fabricación del soporte, por ejemplo, del papel.
// Pap.Col) Color o colores de fabricación del soporte, por ejemplo,
// el color del papel,
// si son varios colores se separar por punto y coma.
// Bck.Tec) Técnicas y materiales empleados para crear la base de la obra
// artística.
// Bck.Col) Color o colores empleados para crear la base de la obra artística,
// si son varios colores se separan por punto y coma, por ejemplo,
// orange; yellow.
// For.Tec) Técnicas y materiales empleado para crear la obra artística.
// For.Col) Color o colores empleados para crear la obra artística,
// si hay más de un color se separan por punto y coma y
// si es un solo color no se emplea el punto y coma, por ejemplo,
// black.
// Pic.Aut) Nombre completo del artista autor de la obra.
// Pic.Own) Nombre del titular propietario actual de la obra,
// ya sea persona física o jurídica,
// o el nombre del último titular conocido o
// un texto genérico de pertenencia a una colección.
// Pic.Prn) Número de reproducciones de la obra artística.
// Pic.Rem) Comentarios que pueden ser en inglés y en castellano y que, a
// diferencia de los comentarios de las agendas de otros sitios web,
// si se publican.
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// CONSTANTS
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Text PdbSep = Repeat("_",78);
//////////////////////////////////////////////////////////////////////////////
PutDescription("Horizontal line between registers.", PdbSep);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// FUNCTIONS
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Set PdbRead(Text inpFil, Set inpBst)
//////////////////////////////////////////////////////////////////////////////
{
Text WriteLn("Reading "+inpFil+"...");
Text inpTxt = Replace(ReadFile(inpFil),PdbSep+"\n","·");
Set inpSet = Tokenizer(inpTxt,"·");
Set inpTab = EvalSet(inpSet, Set(Text inf)
{
Text picCla = TxtBetween2Tag(inf,"<Pic.Cla>", "\n<", TRUE);
Text picSer = TxtBetween2Tag(inf,"<Pic.Ser>", "\n<", TRUE);
Real picWid = Eval(TxtBetween2Tag(inf,"<Pic.Wid>", "\n<", TRUE));
Real picHei = Eval(TxtBetween2Tag(inf,"<Pic.Hei>", "\n<", TRUE));
Date endDte = Eval(TxtBetween2Tag(inf,"<End.Dte>", "\n<", TRUE));
Date updDte = Eval(TxtBetween2Tag(inf,"<Upd.Dte>", "\n<", TRUE));
Text picTxt = TxtBetween2Tag(inf,"<Pic.Num>", "\n<", TRUE);
Real picNum = Eval(picTxt);
Text picTit = TxtBetween2Tag(inf,"<Pic.Tit>", "\n<", TRUE);
Real wrkTim = Eval(TxtBetween2Tag(inf,"<Wrk.Tim>", "\n<", TRUE));
Real wrkQly = Eval(TxtBetween2Tag(inf,"<Wrk.Qly>", "\n<", TRUE));
Set papTec = Txt2Set(TxtBetween2Tag(inf,"<Pap.Tec>", "\n<", TRUE), Empty, TRUE);
Set papCol = Txt2Set(TxtBetween2Tag(inf,"<Pap.Col>", "\n<", TRUE), Empty, TRUE);
Set bckTec = Txt2Set(TxtBetween2Tag(inf,"<Bck.Tec>", "\n<", TRUE), Empty, TRUE);
Set bckCol = Txt2Set(TxtBetween2Tag(inf,"<Bck.Col>", "\n<", TRUE), Empty, TRUE);
Set forTec = Txt2Set(TxtBetween2Tag(inf,"<For.Tec>", "\n<", TRUE), Empty, TRUE);
Set forCol = Txt2Set(TxtBetween2Tag(inf,"<For.Col>", "\n<", TRUE), Empty, TRUE);
Text picAut = TxtBetween2Tag(inf,"<Pic.Aut>", "\n<", TRUE);
Text picOwn = TxtBetween2Tag(inf,"<Pic.Own>", "\n<", TRUE);
Text jpgFil = PagGal+PagNumInt(picNum, TRUE)+".jpg";
Set picSel = Select(inpBst, Real(Set a) { a[1]==picTxt });
Real picPrn = If(EQ(Card(picSel),1), picSel[1][2], 0);
Text picRem = TxtBetween2Tag(inf,"<Pic.Rem>", "\n<", TRUE);
PdbSt(picCla,picSer,picWid,picHei,endDte,updDte,picNum,picTit,
wrkTim,wrkQly,
papTec,papCol,bckTec,bckCol,forTec,forCol,
picAut,picOwn,jpgFil,picPrn,picRem)
});
Set inpSor = Sort(inpTab, Real(Set a, Set b)
{ Compare(a->picNum,b->picNum) });
Text WriteLn("Readed "+FormatReal(Card(inpSor),"%.0lf")+" registers");
inpSor
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Reads and returns a pictures database.",
PdbRead);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Set PdbRenum(Set inpSet)
//////////////////////////////////////////////////////////////////////////////
{
Text WriteLn("Renumering database...");
For(1, Card(inpSet), Set(Real pos)
{
Set reg = inpSet[pos];
PdbSt(reg->picCla,
reg->picSer,
reg->picWid,
reg->picHei,
reg->endDte,
reg->updDte,
pos, // Change picNum for the position
reg->picTit,
reg->wrkTim,
reg->wrkQly,
reg->papTec,
reg->papCol,
reg->bckTec,
reg->bckCol,
reg->forTec,
reg->forCol,
reg->picAut,
reg->picOwn,
reg->jpgFil,
reg->picPrn,
reg->picRem)
})
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns a pictures database where the picNum is the position.",
PdbRenum);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Set PdbLastUpdates(Set inpSet,
Real maxNum)
//////////////////////////////////////////////////////////////////////////////
{
Text WriteLn("Last updates...");
Set selLst = SetFirstNByFun(inpPdb, maxNum, Real(Set a, Set b)
{ Compare(b->updDte,a->updDte) }); // Descending
Set sorLst = Sort(selLst, Real(Set a, Set b)
{ Compare(a->endDte,b->endDte) }); // Ascending
PdbRenum(sorLst) // Renumering
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns the last updates.",
PdbLastUpdates);
//////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
Real Pag2CtrCsv(Set inpPdb) // Pictures database
//////////////////////////////////////////////////////////////////////////////
{
Text imgCsv = "ctr/img.csv"; // Control de visualizaciones en Excel
Text WriteFile(imgCsv,"");
Set cicSet = For(1, maxReg, Real(Real numReg)
{
Set picReg = inpPdb[numReg];
Text AppendFile(imgCsv, FormatReal(picReg->picNum,"%.0lf")+";"+
Replace(picReg->picTit,";"," |")+";"+
dteTxt+";"+
FormatReal(picReg->picPrn,"%.0lf")+";\n");
TRUE
});
Card(cicSet)
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Writes a Csv file in control directory (ctr) with the number, title and
the number of visualizations for statistics.",
Pag2CtrCsv);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Real PdbRenamePic(Set picSet, Text dirPth)
//////////////////////////////////////////////////////////////////////////////
{
Set filSet = GetDir(dirPth)[1];
Set renSet = For(1, Card(picSet), Real(Real picNum)
{
Set picReg = picSet[picNum];
Text filNew = picReg->jpgFil;
Text filOld = filSet[picNum];
FileRename(dirPth+"/"+filOld, dirPth+"/"+filNew)
});
Card(renSet)
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Not useful now.",
PdbRenamePic);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Real PdbInit(Text outFil, Real maxPic)
//////////////////////////////////////////////////////////////////////////////
{
Text txtSee =
"<Pic.Cla> Chp\n"+
"<Pic.Ser> Pho\n"+
"<Pic.Wid> 310\n"+
"<Pic.Hei> 460\n"+
"<End.Dte> y1999m11d30\n"+
"<Upd.Dte> _UPD_\n"+
"<Pic.Num> _NUM_\n"+
"<Pic.Tit> title\n"+
"<Wrk.Tim> 8\n"+
"<Wrk.Qly> 1.00\n"+
"<Pap.Tec> Fabriano paper\n"+
"<Pap.Col> \n"+
"<Bck.Tec> watercolor\n"+
"<Bck.Col> orange\n"+
"<For.Tec> ink\n"+
"<For.Col> black\n"+
"<Pic.Aut> Antonio Salmeron\n"+
"<Pic.Own> Antonio Salmeron\n"+
"<Jpg.Fil> cphpho_NUM_.jpg\n"+
"<Pic.Prn> _PRN_\n"+
"<Pic.Rem> \n"+
"<End>\n";
If(FileExist(outFil), { WriteLn(outFil+" already exists"); 0 },
{
Text WriteFile(outFil, "");
Set wriSet = For(1, maxPic, Real(Real numPic)
{
Date updDte = Succ(y2002m01d01, C, Round(Rand(3,200)));
Text updTxt = FormatDate(updDte,"%cy%Ym%md%d");
Text numTxt = FormatReal(numPic, "%04.0lf");
Text prnTxt = FormatReal(Rand(0,50), "%.0lf");
Text regTxt = ReplaceTable(txtSee,
[[ [["_NUM_", numTxt]],
[["_UPD_", updTxt]],
[["_PRN_", prnTxt]] ]]);
Text regSep = If(EQ(numPic,maxPic), "", PdbSep);
Text AppendFile(outFil, regTxt+regSep+"\n");
TRUE
});
Card(wriSet)
})
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Not used now. This function creates an initial pictures databse.",
PdbInit);
//////////////////////////////////////////////////////////////////////////////
Ink.Watercolor construye las páginas del sitio web inkwatercolor.com
2015 asolver.com | Aviso legal | XHTML | Δ Θ Ξ | Creative Commons | Mapa y funciones del sitio