Secciones de la página

cwx. tol


Declaraciones


Constantes


Variables de control


Funciones


Time oriented language


Árbol de ficheros

Funciones

Set CwxGetLines()

Text CwxTimeIni()

Text CwxClsEndDot()

Text CwxTimeEnd()

Text CwxTimeFix()

Text CwxTranslate()

Real CwxArial8CharWidth()

Real CwxArial8LineWidth()

Set CwxLineWrap()

Set CwxObservations()

Text CwxErrorRow()

Text CwxExcel()

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









cwx.tol de Sfk.Diary

Funciones de conversion del Control actividades en Word a eXcel. Marcadores ¦ 166 (no ) y · 183, sin constantes por claridad del codigo.

Declaraciones

Constantes

  • Real CwxWra
    Caracteres de las observaciones.
  • Real CwxPix
    Pixeles de las observaciones.
  • Text CwxEtc
    Indica que se ha trucado el texto al ser largo.
  • Text CwxTab
    Tabulador para saltas celdas en Excel.
  • Text CwxWee
    Codigo Excel del nombre del dia de la semana.
  • Text CwxYea
    Codigo Excel del año con punto y el numero de mes.
  • Text CwxMth
    Codigo Excel del nombre completo del mes.
  • Text CwxDay
    Hoy si es tarde o ayer si ahora es temprano.

Variables de control

  • Set CwxTre
    Reglas de traduccion particularizables.

Funciones

  • Set CwxGetLines(Text inpTxt)
    Equivalente a Tokenizer() pero retorna los textos compactados y no vacios.
  • Text CwxTimeIni(Text inpTab)
    Si hay una hora de inicio al principio la elimina.
  • Text CwxClsEndDot(Text inpLin)
    Si hay un punto al final del texto lo elimina.
  • Text CwxTimeEnd(Text inpLin)
    Pone un marcador en la duracion de la actividad que hay al final del texto y si no hay duracion asume un cuarto de hora.
  • Text CwxTimeFix(Text inpTxt)
    Trabaja sobre los tiempos y sobre los signos de puntuacion.
  • Text CwxTranslate(Text inpLin, Set cwxTra)
    Aplica todas las reglas de traduccion de las anotaciones de actividad.
  • Real CwxArial8CharWidth(Text oneChr)
    Retorna el ancho en pixels de un caracter en Arial de tamaño 8.
  • Real CwxArial8LineWidth(Text oneLine)
    Retorna el ancho en pixels de un texto en Arial de tamaño 8.
  • Set CwxLineWrap(Text obsFld)
    Version de la funcion TxtLineWrap() que realiza un mejor ajuste cuando el tipo de letra no es de ancho fijo sino proporcional como la Arial. Marca el texto con puntos supensivos cuando lo trunca.
  • Set CwxObservations(Text obsFld)
    Retorna una observacion con la mayuscula inicial y ajustado el texto al ancho en pixels de la columna.
  • Text CwxErrorRow(Text inpLin)
    Retorna una fila Excel para el caso de error.
  • Text CwxExcel(Text inpTxt)
    Retorna un texto convertido en filas Ascii con tabs para pegar en Excel.

Constantes

Real CwxWra

//////////////////////////////////////////////////////////////////////////////
Real CwxWra = 105;
//////////////////////////////////////////////////////////////////////////////
PutDescription("Caracteres de las observaciones.", CwxWra);
//////////////////////////////////////////////////////////////////////////////

Real CwxPix

//////////////////////////////////////////////////////////////////////////////
Real CwxPix = 533;
//////////////////////////////////////////////////////////////////////////////
PutDescription("Pixeles de las observaciones.", CwxPix);
//////////////////////////////////////////////////////////////////////////////

Text CwxEtc

//////////////////////////////////////////////////////////////////////////////
Text CwxEtc = "…";
//////////////////////////////////////////////////////////////////////////////
PutDescription("Indica que se ha trucado el texto al ser largo.", CwxEtc);
//////////////////////////////////////////////////////////////////////////////

Text CwxTab

//////////////////////////////////////////////////////////////////////////////
Text CwxTab = Char(9);
//////////////////////////////////////////////////////////////////////////////
PutDescription("Tabulador para saltas celdas en Excel.", CwxTab);
//////////////////////////////////////////////////////////////////////////////

Text CwxWee

//////////////////////////////////////////////////////////////////////////////
Text CwxWee = Replace("=TEXTO(INDIRECTO('D' &FILA());'dddd')",  "'", "\"");
//////////////////////////////////////////////////////////////////////////////
PutDescription("Codigo Excel del nombre del dia de la semana.", CwxWee);
//////////////////////////////////////////////////////////////////////////////
"

Text CwxYea

//////////////////////////////////////////////////////////////////////////////
Text CwxYea = Replace("=TEXTO(INDIRECTO('D' &FILA());'aa.mm')", "'", "\"");
//////////////////////////////////////////////////////////////////////////////
PutDescription("Codigo Excel del año con punto y el numero de mes.", CwxYea);
//////////////////////////////////////////////////////////////////////////////
"

Text CwxMth

//////////////////////////////////////////////////////////////////////////////
Text CwxMth = Replace("=TEXTO(INDIRECTO('D' &FILA());'mmmm')",  "'", "\"");
//////////////////////////////////////////////////////////////////////////////
PutDescription("Codigo Excel del nombre completo del mes.", CwxMth);
//////////////////////////////////////////////////////////////////////////////
"

Text CwxDay

//////////////////////////////////////////////////////////////////////////////
Text CwxDay = FormatDate(If(Hour(Now)>=18, Today, Succ(Today, C, -1)),
                         "%c%d/%m/%Y"); // 
//////////////////////////////////////////////////////////////////////////////
PutDescription("Hoy si es tarde o ayer si ahora es temprano.", CwxDay);
//////////////////////////////////////////////////////////////////////////////

Variables de control

Set CwxTre

//////////////////////////////////////////////////////////////////////////////
Set  CwxTre = [[
   [[ [["realizado¦", "Realizado¦"]], "¦" ]],
   [[ [["¦ ", "¦,", "¦;", "¦.", " ¦", ",¦", ";¦", ".¦"]], "¦" ]] ]];
//////////////////////////////////////////////////////////////////////////////
PutDescription("Reglas de traduccion particularizables.", CwxTre);
//////////////////////////////////////////////////////////////////////////////

Funciones

Set CwxGetLines()

//////////////////////////////////////////////////////////////////////////////
Set CwxGetLines(Text inpTxt) // Texto de entrada
//////////////////////////////////////////////////////////////////////////////
{
  Set setTok = Tokenizer(inpTxt, "\n");
  Set cutCic = EvalSet(setTok, Text(Text txtTok)
  {
    Real tabPos = TextFind(txtTok, CwxTab);
    Real cutPos = If(tabPos >= 1, tabPos + 1, 1);
    Text cutTxt = Sub(txtTok, cutPos, TextLength(txtTok));
    Compact(cutTxt)
  });
  Select(cutCic, Real(Text inpTok) { inpTok != "" })
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Equivalente a Tokenizer() pero retorna los textos compactados y no vacios.",
CwxGetLines);
//////////////////////////////////////////////////////////////////////////////

Text CwxTimeIni()

//////////////////////////////////////////////////////////////////////////////
Text CwxTimeIni(Text inpTab) // Linea de entrada
//////////////////////////////////////////////////////////////////////////////
{
  Text inpLin = Sub(inpTab, TextFind(inpTab, CwxTab)+1, TextLength(inpTab));
  Real linLen = TextLength(inpLin);
  Text horSep = Sub(inpLin, 3, 3); // Para controlar si hay hora inicial
  Real cutPos = If(horSep == ":", 7, 1); // Con o sin hora inicial
  Sub(inpLin, cutPos, linLen)
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Si hay una hora de inicio al principio la elimina.",
CwxTimeIni);
//////////////////////////////////////////////////////////////////////////////

Text CwxClsEndDot()

//////////////////////////////////////////////////////////////////////////////
Text CwxClsEndDot(Text inpLin) // Linea de entrada ya compactada
//////////////////////////////////////////////////////////////////////////////
{
  Real linLen = TextLength(inpLin);
  Text dotCtr = Sub(inpLin, linLen, linLen); // Controla punto final
  If(dotCtr != ".", inpLin, Sub(inpLin, 1, linLen-1))
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Si hay un punto al final del texto lo elimina.",
CwxClsEndDot);
//////////////////////////////////////////////////////////////////////////////

Text CwxTimeEnd()

//////////////////////////////////////////////////////////////////////////////
Text CwxTimeEnd(Text inpLin) // Linea de entrada ya compactada
//////////////////////////////////////////////////////////////////////////////
{
  Real linLen = TextLength(inpLin);
  Real hasTim = And(Text Sub(inpLin,linLen,  linLen)   <: [["0","5"]],
                    Text Sub(inpLin,linLen-1,linLen-1) <: [["0","2","5","7"]];
                    Text Sub(inpLin,linLen-2,linLen-2) == ",");
  If(!hasTim, inpLin+"¦0,25",
     Sub(inpLin, 1, linLen-6)+"¦"+Sub(inpLin, linLen-3, linLen))
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Pone un marcador en la duracion de la actividad que hay al final del texto y
si no hay duracion asume un cuarto de hora.",
CwxTimeEnd);
//////////////////////////////////////////////////////////////////////////////

Text CwxTimeFix()

//////////////////////////////////////////////////////////////////////////////
Text CwxTimeFix(Text inpTxt)
//////////////////////////////////////////////////////////////////////////////
{
  Set setLin = CwxGetLines(inpTxt);
  Set cicLin = EvalSet(setLin, Text(Text inpLin)
  {
    Text timIni = CwxTimeIni(inpLin);   // Quita las horas de inicio
    Text endDot = CwxClsEndDot(timIni); // Quita los puntos finales
    Text timEnd = CwxTimeEnd(endDot);   // Separa y pone el tiempo dedicado

    "·"+timEnd+"\n"
  });
  Replace(SetSum(cicLin), ";", ",") // Une y unifica ; x ,
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Trabaja sobre los tiempos y sobre los signos de puntuacion.",
CwxTimeFix);
//////////////////////////////////////////////////////////////////////////////

Text CwxTranslate()

//////////////////////////////////////////////////////////////////////////////
Text CwxTranslate(Text inpLin, // Texto de entrada
                  Set  cwxTra) // Reglas de traduccion
//////////////////////////////////////////////////////////////////////////////
{
  Text cwxRep = TxtReplaceTree(inpLin, cwxTra, 0); // Traducir
  Replace(cwxRep, "·", "¦¦¦")   // Poner vacios lo no traducido
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Aplica todas las reglas de traduccion de las anotaciones de actividad.",
CwxTranslate);
//////////////////////////////////////////////////////////////////////////////

Real CwxArial8CharWidth()

//////////////////////////////////////////////////////////////////////////////
Real CwxArial8CharWidth(Text oneChr) // Un caracter + su separacion
//////////////////////////////////////////////////////////////////////////////
{
  Case(
    oneChr<:[["i","l","|",".",",",";",":","!"]],                         1,
    oneChr<:[["j","í"," "]],                                             2,
    oneChr<:[["[","]","{","}","(",")","/","\\"]],                        3,
    oneChr<:[["f","t","I","Í","r","-","*"]],                             3,
    oneChr<:[["x","y","c","s","J","k","v","=","<",">","+","F","Z","T"]], 5,
    oneChr<:[["a","b","d","e","g","h","n","ñ","o","p","q","u","L"]],     5,
    oneChr<:[["0","1","2","3","4","5","6","7","8","9","?"]],             5,
    oneChr<:[["A","Á","E","É","U","Ú"]],                                 6,
    oneChr<:[["X","B","K","P","S","V","C","D","H","N","Ñ","R"]],         6,
    oneChr<:[["Y","G","O","Ó","Q","M","m",CwxEtc]],                      7,
    oneChr<:[["w","%"]],                                                 9,
    oneChr<:[[""]],                                                    10,
    oneChr<:[["W"]],                                                    11,
    TRUE, /* á, é, ó, ú, ... */                                          5
  )+1
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna el ancho en pixels de un caracter en Arial de tamaño 8.",
CwxArial8CharWidth);
//////////////////////////////////////////////////////////////////////////////

Real CwxArial8LineWidth()

//////////////////////////////////////////////////////////////////////////////
Real CwxArial8LineWidth(Text oneLine) // Una linea
//////////////////////////////////////////////////////////////////////////////
{ SetSum(TxtForChr(oneLine, CwxArial8CharWidth)) };
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna el ancho en pixels de un texto en Arial de tamaño 8.",
CwxArial8CharWidth);
//////////////////////////////////////////////////////////////////////////////

Set CwxLineWrap()

//////////////////////////////////////////////////////////////////////////////
Set CwxLineWrap(Text obsFld)
//////////////////////////////////////////////////////////////////////////////
{
  Set  setWra = TxtLineWrap(obsFld, CwxWra, TRUE);
  Text obsWra = setWra[1];
  If(obsWra==obsFld, SetOfText(obsWra, ""), // Cabe
  {
    Real linWid = CwxArial8LineWidth(obsWra); // Ajuste Arial 8 proporcional
    Real addChr = Round(Max(CwxPix - linWid - 7, 0) / 6);
    Set  newWra = TxtLineWrap(obsFld, TextLength(obsWra)+addChr, TRUE);
    SetOfText(newWra[1] + CwxEtc, newWra[2]) // No cabe
  })
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Version de la funcion TxtLineWrap() que realiza un mejor ajuste cuando el
tipo de letra no es de ancho fijo sino proporcional como la Arial.
Marca el texto con puntos supensivos cuando lo trunca.",
CwxLineWrap);
//////////////////////////////////////////////////////////////////////////////

Set CwxObservations()

//////////////////////////////////////////////////////////////////////////////
Set CwxObservations(Text obsFld)
//////////////////////////////////////////////////////////////////////////////
{
  Text obsTUp = ToUpper(Sub(obsFld,1,1)) + Sub(obsFld,2,TextLength(obsFld));
  CwxLineWrap(obsTUp)
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna una observacion con la mayuscula inicial y ajustado el texto al
ancho en pixels de la columna.",
CwxObservations);
//////////////////////////////////////////////////////////////////////////////

Text CwxErrorRow()

//////////////////////////////////////////////////////////////////////////////
Text CwxErrorRow(Text inpLin)
//////////////////////////////////////////////////////////////////////////////
{ Repeat(CwxTab, 8)+inpLin+"\n" };
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna una fila Excel para el caso de error.",
CwxErrorRow);
//////////////////////////////////////////////////////////////////////////////

Text CwxExcel()

//////////////////////////////////////////////////////////////////////////////
Text CwxExcel(Text inpTxt)
//////////////////////////////////////////////////////////////////////////////
{
  Set setLin = CwxGetLines(inpTxt); // Si se quitan las vacias
  Set setSor = Sort(setLin, Compare);

  Set cicLin = EvalSet(setSor, Text(Text inpLin)
  {
    Set  setFld = Txt2Set(inpLin, "¦"); // No se quitan los vacios
    If(Card(setFld) != 5, CwxErrorRow(inpLin),
    {
      Set  obsSet = CwxObservations(setFld[4]);
      Text obsWra = obsSet[1] + If(obsSet[2]=="", "", CwxTab+obsSet[2]);

      setFld[1] + CwxTab + // Entidad
      setFld[2] + CwxTab + // Codigo
      setFld[3] + CwxTab + // Proyecto
      CwxDay    + CwxTab + // Fecha en formato d/m/y
      setFld[5] + CwxTab + // Horas
      CwxWee    + CwxTab + // Dia de la semana
      CwxYea    + CwxTab + // Año con su mes en numero
      CwxMth    + CwxTab + // Nombre del mes
      obsWra    + "\n"     // Observaciones
    })
  });
  SetSum(cicLin)
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna un texto convertido en filas Ascii con tabs para pegar en Excel.",
CwxExcel);
//////////////////////////////////////////////////////////////////////////////

Time oriented language

//////////////////////////////////////////////////////////////////////////////
// FILE    : cwx.tol
// AUTHOR  : http://www.asolver.com
// PURPOSE : Funciones de conversion del Control actividades en Word a eXcel.
// Marcadores ¦ 166 (no ) y · 183, sin constantes por claridad del codigo.
//////////////////////////////////////////////////////////////////////////////


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

//////////////////////////////////////////////////////////////////////////////
Real CwxWra = 105;
//////////////////////////////////////////////////////////////////////////////
PutDescription("Caracteres de las observaciones.", CwxWra);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Real CwxPix = 533;
//////////////////////////////////////////////////////////////////////////////
PutDescription("Pixeles de las observaciones.", CwxPix);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Text CwxEtc = "…";
//////////////////////////////////////////////////////////////////////////////
PutDescription("Indica que se ha trucado el texto al ser largo.", CwxEtc);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Text CwxTab = Char(9);
//////////////////////////////////////////////////////////////////////////////
PutDescription("Tabulador para saltas celdas en Excel.", CwxTab);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Text CwxWee = Replace("=TEXTO(INDIRECTO('D' &FILA());'dddd')",  "'", "\"");
//////////////////////////////////////////////////////////////////////////////
PutDescription("Codigo Excel del nombre del dia de la semana.", CwxWee);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Text CwxYea = Replace("=TEXTO(INDIRECTO('D' &FILA());'aa.mm')", "'", "\"");
//////////////////////////////////////////////////////////////////////////////
PutDescription("Codigo Excel del año con punto y el numero de mes.", CwxYea);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Text CwxMth = Replace("=TEXTO(INDIRECTO('D' &FILA());'mmmm')",  "'", "\"");
//////////////////////////////////////////////////////////////////////////////
PutDescription("Codigo Excel del nombre completo del mes.", CwxMth);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Text CwxDay = FormatDate(If(Hour(Now)>=18, Today, Succ(Today, C, -1)),
                         "%c%d/%m/%Y"); // 
//////////////////////////////////////////////////////////////////////////////
PutDescription("Hoy si es tarde o ayer si ahora es temprano.", CwxDay);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
// CONTROLS
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
Set  CwxTre = [[
   [[ [["realizado¦", "Realizado¦"]], "¦" ]],
   [[ [["¦ ", "¦,", "¦;", "¦.", " ¦", "", "", ""]], "¦" ]] ]];
//////////////////////////////////////////////////////////////////////////////
PutDescription("Reglas de traduccion particularizables.", CwxTre);
//////////////////////////////////////////////////////////////////////////////


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

//////////////////////////////////////////////////////////////////////////////
Set CwxGetLines(Text inpTxt) // Texto de entrada
//////////////////////////////////////////////////////////////////////////////
{
  Set setTok = Tokenizer(inpTxt, "\n");
  Set cutCic = EvalSet(setTok, Text(Text txtTok)
  {
    Real tabPos = TextFind(txtTok, CwxTab);
    Real cutPos = If(tabPos >= 1, tabPos + 1, 1);
    Text cutTxt = Sub(txtTok, cutPos, TextLength(txtTok));
    Compact(cutTxt)
  });
  Select(cutCic, Real(Text inpTok) { inpTok != "" })
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Equivalente a Tokenizer() pero retorna los textos compactados y no vacios.",
CwxGetLines);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Text CwxTimeIni(Text inpTab) // Linea de entrada
//////////////////////////////////////////////////////////////////////////////
{
  Text inpLin = Sub(inpTab, TextFind(inpTab, CwxTab)+1, TextLength(inpTab));
  Real linLen = TextLength(inpLin);
  Text horSep = Sub(inpLin, 3, 3); // Para controlar si hay hora inicial
  Real cutPos = If(horSep == ":", 7, 1); // Con o sin hora inicial
  Sub(inpLin, cutPos, linLen)
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Si hay una hora de inicio al principio la elimina.",
CwxTimeIni);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Text CwxClsEndDot(Text inpLin) // Linea de entrada ya compactada
//////////////////////////////////////////////////////////////////////////////
{
  Real linLen = TextLength(inpLin);
  Text dotCtr = Sub(inpLin, linLen, linLen); // Controla punto final
  If(dotCtr != ".", inpLin, Sub(inpLin, 1, linLen-1))
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Si hay un punto al final del texto lo elimina.",
CwxClsEndDot);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Text CwxTimeEnd(Text inpLin) // Linea de entrada ya compactada
//////////////////////////////////////////////////////////////////////////////
{
  Real linLen = TextLength(inpLin);
  Real hasTim = And(Text Sub(inpLin,linLen,  linLen)   <: [["0","5"]],
                    Text Sub(inpLin,linLen-1,linLen-1) <: [["0","2","5","7"]];
                    Text Sub(inpLin,linLen-2,linLen-2) == ",");
  If(!hasTim, inpLin+"¦0,25",
     Sub(inpLin, 1, linLen-6)+"¦"+Sub(inpLin, linLen-3, linLen))
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Pone un marcador en la duracion de la actividad que hay al final del texto y
si no hay duracion asume un cuarto de hora.",
CwxTimeEnd);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Text CwxTimeFix(Text inpTxt)
//////////////////////////////////////////////////////////////////////////////
{
  Set setLin = CwxGetLines(inpTxt);
  Set cicLin = EvalSet(setLin, Text(Text inpLin)
  {
    Text timIni = CwxTimeIni(inpLin);   // Quita las horas de inicio
    Text endDot = CwxClsEndDot(timIni); // Quita los puntos finales
    Text timEnd = CwxTimeEnd(endDot);   // Separa y pone el tiempo dedicado

    "·"+timEnd+"\n"
  });
  Replace(SetSum(cicLin), ";", ",") // Une y unifica ; x ,
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Trabaja sobre los tiempos y sobre los signos de puntuacion.",
CwxTimeFix);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Text CwxTranslate(Text inpLin, // Texto de entrada
                  Set  cwxTra) // Reglas de traduccion
//////////////////////////////////////////////////////////////////////////////
{
  Text cwxRep = TxtReplaceTree(inpLin, cwxTra, 0); // Traducir
  Replace(cwxRep, "·", "¦¦¦")   // Poner vacios lo no traducido
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Aplica todas las reglas de traduccion de las anotaciones de actividad.",
CwxTranslate);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Real CwxArial8CharWidth(Text oneChr) // Un caracter + su separacion
//////////////////////////////////////////////////////////////////////////////
{
  Case(
    oneChr<:[["i","l","|",".",",",";",":","!"]],                         1,
    oneChr<:[["j","í"," "]],                                             2,
    oneChr<:[["[","]","{","}","(",")","/","\\"]],                        3,
    oneChr<:[["f","t","I","Í","r","-","*"]],                             3,
    oneChr<:[["x","y","c","s","J","k","v","=","<",">","+","F","Z","T"]], 5,
    oneChr<:[["a","b","d","e","g","h","n","ñ","o","p","q","u","L"]],     5,
    oneChr<:[["0","1","2","3","4","5","6","7","8","9","?"]],             5,
    oneChr<:[["A","Á","E","É","U","Ú"]],                                 6,
    oneChr<:[["X","B","K","P","S","V","C","D","H","N","Ñ","R"]],         6,
    oneChr<:[["Y","G","O","Ó","Q","M","m",CwxEtc]],                      7,
    oneChr<:[["w","%"]],                                                 9,
    oneChr<:[[""]],                                                    10,
    oneChr<:[["W"]],                                                    11,
    TRUE, "/* á, é, ó, ú, ... */                                          5
  )+1
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna el ancho en pixels de un caracter en Arial de tamaño 8.",
CwxArial8CharWidth);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Real CwxArial8LineWidth(Text oneLine) // Una linea
//////////////////////////////////////////////////////////////////////////////
{ SetSum(TxtForChr(oneLine, CwxArial8CharWidth)) };
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna el ancho en pixels de un texto en Arial de tamaño 8.",
CwxArial8CharWidth);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Set CwxLineWrap(Text obsFld)
//////////////////////////////////////////////////////////////////////////////
{
  Set  setWra = TxtLineWrap(obsFld, CwxWra, TRUE);
  Text obsWra = setWra[1];
  If(obsWra==obsFld, SetOfText(obsWra, ""), // Cabe
  {
    Real linWid = CwxArial8LineWidth(obsWra); // Ajuste Arial 8 proporcional
    Real addChr = Round(Max(CwxPix - linWid - 7, 0) / 6);
    Set  newWra = TxtLineWrap(obsFld, TextLength(obsWra)+addChr, TRUE);
    SetOfText(newWra[1] + CwxEtc, newWra[2]) // No cabe
  })
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Version de la funcion TxtLineWrap() que realiza un mejor ajuste cuando el
tipo de letra no es de ancho fijo sino proporcional como la Arial.
Marca el texto con puntos supensivos cuando lo trunca.",
CwxLineWrap);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Set CwxObservations(Text obsFld)
//////////////////////////////////////////////////////////////////////////////
{
  Text obsTUp = ToUpper(Sub(obsFld,1,1)) + Sub(obsFld,2,TextLength(obsFld));
  CwxLineWrap(obsTUp)
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna una observacion con la mayuscula inicial y ajustado el texto al
ancho en pixels de la columna.",
CwxObservations);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Text CwxErrorRow(Text inpLin)
//////////////////////////////////////////////////////////////////////////////
{ Repeat(CwxTab, 8)+inpLin+"\n" };
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna una fila Excel para el caso de error.",
CwxErrorRow);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Text CwxExcel(Text inpTxt)
//////////////////////////////////////////////////////////////////////////////
{
  Set setLin = CwxGetLines(inpTxt); // Si se quitan las vacias
  Set setSor = Sort(setLin, Compare);

  Set cicLin = EvalSet(setSor, Text(Text inpLin)
  {
    Set  setFld = Txt2Set(inpLin, "¦"); // No se quitan los vacios
    If(Card(setFld) != 5, CwxErrorRow(inpLin),
    {
      Set  obsSet = CwxObservations(setFld[4]);
      Text obsWra = obsSet[1] + If(obsSet[2]=="", "", CwxTab+obsSet[2]);

      setFld[1] + CwxTab + // Entidad
      setFld[2] + CwxTab + // Codigo
      setFld[3] + CwxTab + // Proyecto
      CwxDay    + CwxTab + // Fecha en formato d/m/y
      setFld[5] + CwxTab + // Horas
      CwxWee    + CwxTab + // Dia de la semana
      CwxYea    + CwxTab + // Año con su mes en numero
      CwxMth    + CwxTab + // Nombre del mes
      obsWra    + "\n"     // Observaciones
    })
  });
  SetSum(cicLin)
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna un texto convertido en filas Ascii con tabs para pegar en Excel.",
CwxExcel);
//////////////////////////////////////////////////////////////////////////////

Árbol de ficheros

Sfk.Diary conversor de notas escritas de Word a Excel a traves del clipboard

  • make.tol programa de conversion con reglas de reescritura .doc a .xls
  • tol directorios de codigo fuente escrito en lenguaje Tol
    • cmm directorio de funciones comunes de texto y para el clipboard
      • txt.tol funciones para el manejo de textos
      • sfk.tol funciones para manejar sfk169.exe de Swiss File Knife
    • app funciones especificas de aplicacion de la conversion de notas
      • cwx.tol funciones de conversion del Control notas en Word a eXcel
    • inc.tol fichero para la inclusion de ficheros en lenguaje Tol
  • ../../Bin/sfk directorio para los mandatos de la herramienta Swiss File Knife
  • sfk_diary.pdf documento resumen de funciones del programa de conversion

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

Tol