Funciones para una agenda de posts.
Constantes
Text PdbSepFunciones
Set PdbRead(Text inpFil)Text PdbIndex(Set setPdb)Text PdbTxtKeyword(Set setPdb, Real maxWrd)Set PdbFrm(Real pdbPos, Real ctrMax, Set frmTab, Real ctrRnd)Text PdbGetRand(Text inpTxt, Text iniTag)Text PdbGetDescription(Text inpTxt)//////////////////////////////////////////////////////////////////////////////
Text PdbSep = Repeat("_",78);
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Separador de los post en la agenda de contenidos.",
PdbSep);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Set PdbRead(Text inpFil)
//////////////////////////////////////////////////////////////////////////////
{
Text WriteLn("Reading "+inpFil+"...");
Text inpTxt = Replace(ReadFile(inpFil), PdbSep+"\n", Char(7));
Set inpSet = Tokenizer(inpTxt, Char(7));
Text fldEnd = "\n<Pst.";
Set inpTab = EvalSet(inpSet, Set(Text inpPst)
{
Text iniSta = TxtBetween2Tag(inpPst,"<Pst.Sta>", fldEnd, TRUE);
Text pstSta = Sub(iniSta+"C",1,1); // C por defecto
Text filNam = TxtBetween2Tag(inpPst,"<Pst.Fil>", fldEnd, TRUE);
// Antes se sorteaba en lectura un titulo que se usaba en todas las páginas.
// Ahora se sortea en escritura por lo que la aleatoriedad es aun mayor.
// Text titLar = PdbGetRand (inpPst,"<Pst.Tit>");
Text titLar = TxtBetween2Tag(inpPst,"<Pst.Tit>", fldEnd, TRUE);
// Text iniSor = PdbGetRand( inpPst,"<Pst.Lbl>");
Text iniSor = TxtBetween2Tag(inpPst,"<Pst.Lbl>", fldEnd, TRUE);
Text titSor = If(iniSor!="", iniSor, titLar); // Si no hay -> el largo
// Text titSub = PdbGetRand (inpPst,"<Pst.Sub>");
Text titSub = TxtBetween2Tag(inpPst,"<Pst.Sub>", fldEnd, TRUE);
Text pstHtm = TxtBetween2Tag(inpPst,"<Pst.Htm>", fldEnd, FALSE);
Text pstDes = PdbGetDescription(pstHtm);
PdbSt(pstSta, filNam, titLar, titSor, titSub, pstHtm, pstDes)
});
Set inpSel = Select(inpTab, Real(Set pstObj)
{ pstObj->pstSta != "A" }); // No Anulados
Set selSet = Select(inpSel, Real(Set pstObj)
{ pstObj->filNam != "" }); // Con nombre de fichero
Set selCla = Classify(selSet, Real(Set a, Set b) // Check ficheros dobles
{ Compare(a->filNam, b->filNam) });
Set selDup = Select(selCla, Real(Set claSet) { GT(Card(claSet),1) });
Set wriDup = EvalSet(selDup, Real(Set claSet)
{ Text WriteLn("Repeated: "+claSet[1]->filNam); TRUE });
Text WriteLn("Readed Ok "+F(Card(selSet))+" registers");
Text WriteLn("Status ABC "+F(Card(inpTab))+" registers");
Text WriteLn("Status _BC "+F(Card(inpSel))+" registers");
selSet
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Lee y retorna una estructura de posts en el mismo orden de lectura la agenda.
Los posts anulados, con su estado a A no son retornados.
Si un post no tiene estado se asume el estado C, que es el común.",
PdbRead);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Text PdbIndex(Set setPdb) // Set of post
//////////////////////////////////////////////////////////////////////////////
{
Set indCic = EvalSet(setPdb, Text(Set pdbObj) // Index
{
" <li><a href='" + pdbObj->filNam + ".html'>" +
R(pdbObj->titLar) + "</a>" +
": "+ R(pdbObj->titSub) + ".</li>\n"
});
"\n <ul>\n" + SetSum(indCic) + " </ul>\n"
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna un indice para un conjunto de posts.",
PdbIndex);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Text PdbTxtKeyword(Set setPdb, // Set of post
Real maxWrd) // Average of word for a random number
//////////////////////////////////////////////////////////////////////////////
{
Text setKey = KeyWord(
EvalSet(setPdb, Text(Set pst)
{
pst->titLar+" "+
pst->titSub+" "+
pst->titSor+" "+
TxtOutHtmTag(pst->pstHtm)
}),
5, FALSE, Round(Rand(maxWrd-5, maxWrd+5)));
ReplaceTable(setKey,
[[ [["antonio", ""]],
[["salmerón", ""]],
[["cabañas", ""]],
[[", ,", ","]] ]])
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna un texto con las maxWrd keywords de un conjunto de posts.",
PdbTxtKeyword);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Set PdbFrm(Real pdbPos, // Post position
Real ctrMax, // Maximum of images
Set frmTab, // Forms tab
Real ctrRnd) // If true ramdom, else secuential
//////////////////////////////////////////////////////////////////////////////
{
Real frmCrd = Card(frmTab);
Real frmIni = If(ctrRnd,
Min(frmCrd, Max(1, Round(Rand(0,frmCrd)+0.5))), // Aleatorio
(1+(pdbPos-1)*CtrMax) % Card(frmTab)); // Secuencial
SetSubCicle(frmTab, frmIni, CtrMax)
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna un conjunto de ctrMax imagenes de formularios y los puede elegir de
forma secuencial a partir de pdbPos o de forma aleatoria.",
PdbFrm);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Text PdbGetRand(Text inpTxt, // Texto de un post
Text iniTag) // Inicio del nombre del campo
//////////////////////////////////////////////////////////////////////////////
{
Text subTxt = TxtBetween2Tag(inpTxt, iniTag, "\n<Pst.", TRUE);
If(subTxt=="", "", R(subTxt))
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna un texto del campo que comienza con fldIni del texto pstTxt de un
post, si existen varias altertanivas de texto retorna una al azar.
Se retorna compactado.",
PdbGetRand);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Text PdbGetDescription(Text inpTxt) // Texto de un post
//////////////////////////////////////////////////////////////////////////////
{
Text iniTag = "<p class="+Q("PutDes")+">";
Text subTxt = TxtBetween2Tag(inpTxt, iniTag, "</p>", TRUE);
Text clsTxt = TxtOutHtmTag(subTxt);
Compact(clsTxt)
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna la descripcion del post que es el parrafo principal.",
PdbGetDescription);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// FILE : pdb.tol
// AUTHOR : http://www.asolver.com
// PURPOSE : Funciones para una agenda de posts.
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// CONSTANTS
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Text PdbSep = Repeat("_",78);
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Separador de los post en la agenda de contenidos.",
PdbSep);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// FUNCTIONS
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Set PdbRead(Text inpFil)
//////////////////////////////////////////////////////////////////////////////
{
Text WriteLn("Reading "+inpFil+"...");
Text inpTxt = Replace(ReadFile(inpFil), PdbSep+"\n", Char(7));
Set inpSet = Tokenizer(inpTxt, Char(7));
Text fldEnd = "\n<Pst.";
Set inpTab = EvalSet(inpSet, Set(Text inpPst)
{
Text iniSta = TxtBetween2Tag(inpPst,"<Pst.Sta>", fldEnd, TRUE);
Text pstSta = Sub(iniSta+"C",1,1); // C por defecto
Text filNam = TxtBetween2Tag(inpPst,"<Pst.Fil>", fldEnd, TRUE);
// Antes se sorteaba en lectura un titulo que se usaba en todas las páginas.
// Ahora se sortea en escritura por lo que la aleatoriedad es aun mayor.
// Text titLar = PdbGetRand (inpPst,"<Pst.Tit>");
Text titLar = TxtBetween2Tag(inpPst,"<Pst.Tit>", fldEnd, TRUE);
// Text iniSor = PdbGetRand( inpPst,"<Pst.Lbl>");
Text iniSor = TxtBetween2Tag(inpPst,"<Pst.Lbl>", fldEnd, TRUE);
Text titSor = If(iniSor!="", iniSor, titLar); // Si no hay -> el largo
// Text titSub = PdbGetRand (inpPst,"<Pst.Sub>");
Text titSub = TxtBetween2Tag(inpPst,"<Pst.Sub>", fldEnd, TRUE);
Text pstHtm = TxtBetween2Tag(inpPst,"<Pst.Htm>", fldEnd, FALSE);
Text pstDes = PdbGetDescription(pstHtm);
PdbSt(pstSta, filNam, titLar, titSor, titSub, pstHtm, pstDes)
});
Set inpSel = Select(inpTab, Real(Set pstObj)
{ pstObj->pstSta != "A" }); // No Anulados
Set selSet = Select(inpSel, Real(Set pstObj)
{ pstObj->filNam != "" }); // Con nombre de fichero
Set selCla = Classify(selSet, Real(Set a, Set b) // Check ficheros dobles
{ Compare(a->filNam, b->filNam) });
Set selDup = Select(selCla, Real(Set claSet) { GT(Card(claSet),1) });
Set wriDup = EvalSet(selDup, Real(Set claSet)
{ Text WriteLn("Repeated: "+claSet[1]->filNam); TRUE });
Text WriteLn("Readed Ok "+F(Card(selSet))+" registers");
Text WriteLn("Status ABC "+F(Card(inpTab))+" registers");
Text WriteLn("Status _BC "+F(Card(inpSel))+" registers");
selSet
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Lee y retorna una estructura de posts en el mismo orden de lectura la agenda.
Los posts anulados, con su estado a A no son retornados.
Si un post no tiene estado se asume el estado C, que es el común.",
PdbRead);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Text PdbIndex(Set setPdb) // Set of post
//////////////////////////////////////////////////////////////////////////////
{
Set indCic = EvalSet(setPdb, Text(Set pdbObj) // Index
{
" <li><a href='" + pdbObj->filNam + ".html'>" +
R(pdbObj->titLar) + "</a>" +
": "+ R(pdbObj->titSub) + ".</li>\n"
});
"\n <ul>\n" + SetSum(indCic) + " </ul>\n"
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna un indice para un conjunto de posts.",
PdbIndex);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Text PdbTxtKeyword(Set setPdb, // Set of post
Real maxWrd) // Average of word for a random number
//////////////////////////////////////////////////////////////////////////////
{
Text setKey = KeyWord(
EvalSet(setPdb, Text(Set pst)
{
pst->titLar+" "+
pst->titSub+" "+
pst->titSor+" "+
TxtOutHtmTag(pst->pstHtm)
}),
5, FALSE, Round(Rand(maxWrd-5, maxWrd+5)));
ReplaceTable(setKey,
[[ [["antonio", ""]],
[["salmerón", ""]],
[["cabañas", ""]],
[[", ,", ","]] ]])
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna un texto con las maxWrd keywords de un conjunto de posts.",
PdbTxtKeyword);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Set PdbFrm(Real pdbPos, // Post position
Real ctrMax, // Maximum of images
Set frmTab, // Forms tab
Real ctrRnd) // If true ramdom, else secuential
//////////////////////////////////////////////////////////////////////////////
{
Real frmCrd = Card(frmTab);
Real frmIni = If(ctrRnd,
Min(frmCrd, Max(1, Round(Rand(0,frmCrd)+0.5))), // Aleatorio
(1+(pdbPos-1)*CtrMax) % Card(frmTab)); // Secuencial
SetSubCicle(frmTab, frmIni, CtrMax)
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna un conjunto de ctrMax imagenes de formularios y los puede elegir de
forma secuencial a partir de pdbPos o de forma aleatoria.",
PdbFrm);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Text PdbGetRand(Text inpTxt, // Texto de un post
Text iniTag) // Inicio del nombre del campo
//////////////////////////////////////////////////////////////////////////////
{
Text subTxt = TxtBetween2Tag(inpTxt, iniTag, "\n<Pst.", TRUE);
If(subTxt=="", "", R(subTxt))
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna un texto del campo que comienza con fldIni del texto pstTxt de un
post, si existen varias altertanivas de texto retorna una al azar.
Se retorna compactado.",
PdbGetRand);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Text PdbGetDescription(Text inpTxt) // Texto de un post
//////////////////////////////////////////////////////////////////////////////
{
Text iniTag = "<p class="+Q("PutDes")+">";
Text subTxt = TxtBetween2Tag(inpTxt, iniTag, "</p>", TRUE);
Text clsTxt = TxtOutHtmTag(subTxt);
Compact(clsTxt)
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna la descripcion del post que es el parrafo principal.",
PdbGetDescription);
//////////////////////////////////////////////////////////////////////////////
Omr.Forms construye las páginas web Html del sitio web omrforms.es
2015 asolver.com | Aviso legal | XHTML | Δ Θ Ξ | Creative Commons | Mapa y funciones del sitio