[ Foro de Pascal ]

Falla en compilación

02-Jul-2024 05:50
Invitado (FLOROVSKI)
1 Respuestas

hola, estoy escribiendo este subcodigo en pascal y aparantemente tiene fallas en la compilacion, me podrian decir cual es el error?

function todosTienenFormatoEnLinea ( tfmt : TipoFormato; ini, fin : RangoColumna; ln : Linea ) : boolean;
{Precondiciones: 1 <= ini <= ln.tope  1 <= fin <= ln.tope }
var i:RangoColumna;
   formatogeneral: boolean;
begin
i:= ini;
formatogeneral:= true;
 while formatogeneral and (i<= fin) do
 begin
  if ln[i].fmt <> tfmt then
   begin
    formatogeneral:= false;
   end;
  i:= i+1;
 end;
 todosTienenFormatoEnLinea:= formatogeneral;
end;


procedure aplicarFormatoEnLinea ( tfmt : TipoFormato; ini, fin : RangoColumna; var ln : Linea );
{  Precondiciones: 1 <= ini <= ln.tope  1 <= fin <= ln.tope }
var
 i: RangoColumna;
 existeformato: boolean;
begin
 existeformato := true;
 i := ini;
 
 while i <= fin do
 begin
   if ln[i].formato <> tfmt then
   begin
     existeformato := false;
   end;
   i := i + 1;
 end;
 
 if existeformato then
 begin
   i := ini;
   while i <= fin do
   begin
     ln[i].formato := SinFormato;
     i := i + 1;
   end;
 end
 else
 begin
   i := ini;
   while i <= fin do
   begin
     ln[i].formato := tfmt;
     i := i + 1;
   end;
 end;
end;

function contarCaracteresEnTexto ( txt : Texto ) : integer;
{ se necesita un contador de caracteres}
var i, contador: integer; { determinamos variables para el contador}
begin
contador:=0;
for i:=1 to txt.tope do
contador:= contador+ txt.lineas[i].tope;
contarCaracteresEnTexto:=contador;
end;

procedure buscarCadenaEnLineaDesde ( c : Cadena; ln : Linea; desde : RangoColumna; var pc : PosibleColumna );
{ Precondiciones: 1 <= desde <= ln.tope }
var i, j: RangoColumna;  
 encontrada: boolean;  

begin
 encontrada := false;  
 pc := 0;  
 i := desde;  
 while (i <= ln.tope) and not encontrada do  
  begin
   encontrada := true;  
   j := 1;  
    while encontrada and (j <= c.tope) do  
     begin
      if ln[i + j - 1].car <> c[j] then  
       encontrada := false;  
       j := j + 1;  
     end;
   if encontrada then
     pc := i;  
   i := i + 1;  
   end;
end;

procedure buscarCadenaEnTextoDesde ( c : Cadena; txt : Texto; desde : Posicion; var pp : PosiblePosicion );
{ Precondiciones: 1 <= desde.linea <= cantidad de líneas  1 <= desde.columna <= tope de línea en desde.linea }
var i, f, m: integer;
   lenC, lenLinea: integer;
   coincidencia, busqueda: boolean;
begin
   lenC := length(c);
   pp.coincidencia := false;
   i := desde.linea;
   busqueda:= true;
 while (i <= 100) and (not pp.coincidencia) do
   begin
     lenLinea := length(txt[i]);
       if i = desde.linea then
           j := desde.columna
        else
           j := 1;
       while (j <= lenLinea - lenC + 1) and (busqueda) do
        begin
           coincidencia := true;
           k := 1;
           while (k <= lenC) and coincidencia do
           begin
               if txt[i][j + k - 1] <> c[k] then
                   coincidencia := false;
               k := k + 1;
           end;
          if coincidencia then
           begin
               pp.coincidencia := true;
               pp.posicion.linea := i;
               pp.posicion.columna := j;
               busqueda := false;
           end;
           j := j + 1;
       end;
       i := i + 1;
   end;
end;

procedure insertarCadenaEnLinea ( c : Cadena; columna : RangoColumna; var ln : linea; var pln : PosibleLinea );
{ Precondiciones:  1 <= columna <= ln.tope+1
   columna <= MAXCOL
   c.tope + columna <= MAXCOL  }  
   var i:= integer
begin
if (c.tope + columna > MAXCOL) then
 begin
   pln.eslinea := true;
   pln.l.tope := 0;
   for i := 1 to (c.tope + ln.tope - MAXCOL) do
   begin
     pln.l[i].car := ln[columna + c.tope + i - 1].car;
   end;
 end
 else
 begin
   pln.eslinea := false;
   for i := (columna + c.tope) downto (columna + 1) do
   begin
     ln[i].car := ln[i - c.tope].car;
     ln[i].fmt := ln[i - c.tope].fmt;
   end;
   for i := 1 to c.tope do
   begin
     ln[columna + i - 1].car := c[i].car;
     ln[columna + i - 1].fmt := tfmt;
   end;
 end;
end;

procedure insertarLineaEnTexto ( ln : Linea; nln : integer; var txt : Texto );
{ Inserta la línea `ln` en la posición `nlin` del texto `txt`.
 Precondiciones: 1 < nln <= cantidad de líneas del texto + 1}
var
 i: integer;
begin
 for i := txt.tope downto nln + 1 do
   txt.lineas[i] := txt.lineas[i - 1];
 txt.lineas[nln] := ln;
 txt.tope := txt.tope + 1;
end;


06-Jul-2024 13:59
Nacho Cabanes (+84)

Faltan cosas para poder probarlo. Por ejemplo, mencionas unos tipos de datos "TipoFormato" "RangoColumna" y "Linea".






(No se puede continuar esta discusión porque tiene más de dos meses de antigüedad. Si tienes dudas parecidas, abre un nuevo hilo.)