home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.pascal.borland      Borland Pascal was actually pretty neat      2,978 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 1,498 of 2,978   
   Rudolf Wiesendanger to jb   
   Re: AYUDA PASCAL URGE PARA PRACTICA   
   05 Apr 05 00:12:36   
   
   From: ruediw@Hispeed.ch   
      
   On 04 Apr 2005, you wrote in comp.lang.pascal.borland:   
      
    > Me sale error 202 Stack Overflow y nose porque.   
    > Alguna idea?   
    > Gracias   
      
   I think You made many errors in Your code...   
   Does it really compile ??   
    >   
    > Adjunto el fuente .pas   
    >   
    >:   
    >   
    > program academia;   
    > uses crt;   
      
   I would declare:   
   Type   
      Str50 : String[50];   
      
    > type   
    >   alumn= record   
    >     Codigo:byte; {Lo uso para el turno 1,2 ¢ 3}   
    >     apellidos:String[50];   
    >     edad:byte;   
    > end;   
      
   I would declare   
   Const   
      Amin = 1;   
      Amax = 10;   
      Bmin = 10;   
      Bmax = 50;   
      
   Result:   
   Type   
      curso = array[Amin..Amax,Bmin..Bmax] of alumn;{10 cursos,a 30 alumnos   
   maximo por >   curso}   
      
    > const   
    >   coste= 10.000;   
      
    > var   
    >   tabalumnos:curso;   
      
      
    > Function MiraHueco(tabla:curso;curso:byte;turno:byte):byte;{Devuelve 0   
   { I would use an other Name hier ----^ I think its confusing .... }   
      
    > si no hay hueco en el turno}   
    > {Alumnos por turno}   
    > const   
    >   alporturno=10;   
    > var i,j:byte;{Para bucle for}   
    >  begin   
     Next line is unneded ...   
    >    i:=1;   
      
    >    j:=alporturno;   
    >    For i:= 1 to 30 do   
    >     begin   
    >     if ta     bla[curso,i].codigo=turnothendec   
   I think that would not compile --^   
    >     end;   
    >   mirahueco:=j;   
    >  end;   
    >   
     {Buscaposicion libre en tabla curso}   
       Function Buscaposicion(tabcursos:curso;cur:byte):byte;   
       var   
         i,Apos:byte; {I would not name a var 'pos' (there is a function   
   with this name too ...)   
   Variable pos has a random value here ....   
        Apos := 0;  {allwais the same value at entry}   
      
    >   begin   
   Don't change the var used in a For ... to loop ...   
    >    for i:=1 to 30 do   
    >       if tabcursos[cur,i].codigo=0 then i:=pos;   
    >       Buscaposicion:=pos;   
    >   end;   
    >   
      
    > Procedure Muestracursos;   
    > begin   
    >  clrscr;   
    >  writeln('En que curso quiere matricularse?');   
    >  writeln('1.- Windows');   
    >  writeln('2.- Linux');   
    >  writeln('3.- Excel');   
    >  writeln('4.- Access');   
    >  writeln('5.- Java');   
    >  writeln('6.- Pascal');   
    >  writeln('7.- C++');   
    >  writeln('8.- JSP');   
    >  writeln('9.- Delphi');   
    >  writeln('10.-XML');   
    > end;   
    >   
    > Procedure alumnomascursos(edad:byte;apellidos:string;var tabla:curso);   
    > var poshueco,hueco,cur,tur:byte;      tecla:char;   
     begin   
   Next line not needed ...   
    >  clrscr;   
    >   {write('De que curso desea matricularse > ?')};   
         Muestracursos;   
   Better:   
       repeat   
          readln(cur);   
    >  until cur IN [1..10];   
   Better:   
       write('En que turno desea matricularse ? (1,2,3)');   
       repeat   
          readln(tecla);   
       until tur IN ['1'..'3'];   
   or use readkey ...   
    >  hueco:=Mirahueco(tabla,cur,tur);   
   Better:   
      
      if hueco <> 0 then{Hay hueco en el curso,y turno elegido}   
      begin   
        poshueco := Buscaposicion(tabla,cur);   
     { ???????? start }   
        tabla[cur,poshueco].apellidos:=apellidos;   
        tabla[cur,poshueco].codigo:=tur;   
        tabla[cur,poshueco].edad:=edad;   
     { ??????? end }   
        Write('Desea Matricularse en otro curso S/N');   
        Repeat   
          tecla := Upcase(readkey);   
        Until (Tecla = 'S') or (Tecla = 'N');   
    >   case tecla of   
    >     'n','N':{menu;}exit;   
    >     's','S':alumnomascursos(edad,apellidos,tabla);   
    >   end;{del case}   
      End  { end if ....}   
      Else   
      Begin   
        write('No hay hueco en ese turno,pulse cualquier tecla para volver   
        al menu');   
    >   tecla := readkey;   
      End;   
    > end;{Procedur}   
    >   
    >   
    >   
    > Procedure Nuevoalumno(var al:alumn;var tabla:curso);   
    > var cur,tur,hueco,poshueco,edad:byte;{Curso y turno seleccionado}   
    >  apellidos:string[50];      tecla:char;   
    >  begin   
    >   repeat   
    >   write('De que curso quiere matricularse   
    > ?');Muestracursos;readln(cur);   
    >   until cur IN [1..10];   
    >   repeat   
   Here i would take tecla (menu ???)   
    >   write('En que turno quiere matricularse ? (1,2,3)');readln(tur);   
    >   until tur IN [1..3];   
    >   hueco:=Mirahueco(tabla,cur,tur);   
    >   if hueco=0 then   
    >    begin   
    >     write('No hay hueco en ese turno,pulse cualquier tecla para volver   
    > al menu');   
    >     readkey;{menu;}exit;   
    >    end;   
    >   if hueco<>0 then{Hay hueco en el curso,y turno elegido}   
    >   begin   
    >   poshueco:=Buscaposicion(tabla,cur);   
    >   writeln('Introduzca Apellidos,y luego pulse   
    > enter');readln(apellidos);   
    >   tabla[cur,poshueco].apellidos:=apellidos;   
    >   tabla[cur,poshueco].codigo:=tur;   
    >   writeln('Introduzca su edad,y luego pulse enter');readln(edad);   
    >   gotoxy(wherex,wherey-2);delline;   
    >   tabla[cur,poshueco].edad:=edad;   
    >   writeln('Desea Matricularse en otro curso ?   
    > S/N');readkey;tecla:=readkey;   
    >   case tecla of   
    >   'n','N':{menu;}exit;   
    >   's','S':alumnomascursos(edad,apellidos,tabla)   
    >   end;{Case of }   
    >  end;{if}   
    >  end;{Del procedure nuevoalumno}   
    >   
    >   
    > Procedure Initablero(var tabla:curso);   
    > var i,j:byte;   
    >  begin   
    >  for i:=1 to 10 do   
    >   begin   
    >   for j:=1 to 30 do   
    >    begin   
    >    tabla[i,j].codigo=0   
    >   tabla[i,j].edad:=0;   
    >   tabla[i,j].apellidos:=('');   
    >   end;   
    >   end;   
    > end;   
      
   Suggestion:   
   Procedure WriteXy(row, Col : Byte; St : String);   
   Begin   
      GotoXy(Row,Col);   
      Write(st);   
   End;   
      
      
     Procedure Menu;   
     var   
        tecla:char;   
     alumno:   
        alumn;   
      
     begin  {begin procedure}   
       clrscr;   
       Repeat   
   Then this changes to:   
        WriteXY(20,7,'MENU PRINCIPAL');   
        WriteXY(20,8,'--------------');   
        WriteXY(20,10,'1.- A¤adir un alumno a un curso.');   
        WriteXY(20,11,'2.- Listado de alumnos de un curso completo.');   
        WriteXY(20,12,'3.- Contabilidad.');   
        WriteXY(20,13,'0.- Salir.');   
   I would:   
        Repeat   
          tecla := readkey;   
        Until tecla in ['0'..'3'];   
        case tecla of   
        '1':Nuevoalumno(alumno,tabalumnos);   
        '2':write('ListadoCurso');   
        '3':write('Total');   
        end;   
        until tecla='0'   
     end;  { End menu }   
      
   begin   
      initablero(tabalumnos);   
      menu;   
   end.   
      
      
   Hope this helps...   
   Rudolf   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca