Ver Mensaje Individual
  #5  
Antiguo 07-04-2004
Telemaco Telemaco is offline
Miembro
 
Registrado: feb 2004
Posts: 50
Reputación: 21
Telemaco Va por buen camino
Hola GuillotMarc

este es el codigo del procedimiento CalcFields
var
manyana,tarde:boolean;
M1,M2,T1,T2:String;
op,hor,min:integer;

h1,h2:string;
ht : array [0..2] of char;
mt : array [0..5] of char;
x:STRING;

m,t:Tdatetime;
horas:string;
i:byte;
hh,mm:string;
hint,mint:integer;

begin
op:= strtoint(FCronos.TipoAccion.text);
case op of
1 : {Actualizo los campos autocalculados'}
begin
manyana:=false;
tarde:=false;
if Tfichajes.FieldByName('HoraEntM').AsString >'00:00:00'
then begin
M1:=TFichajes.FieldbyName('HoraEntM').AsString;
end
else begin
manyana:=true;
{ M1:='07:07:00';}
end;
if (TFichajes.FieldByName('HoraSalM').AsString) > '00:00:00'
then begin
M2:=Tfichajes.FieldByName('HoraSalM').Asstring;
end
else begin
manyana:=true;
{ M2:='13:33:00'}
end;
if TFichajes.FieldByName('HoraEntT').AsString > '00:00:00'
then begin
T1:=Tfichajes.fieldbyname('HoraEntT').AsString;
end
else begin
Tarde:=true;
end;
if TFichajes.FieldByName('HoraSalT').AsString > '00:00:00'
then begin
T2:=Tfichajes.fieldbyname('HoraSalT').AsString;
end
else begin
Tarde:=true;
end;

if not manyana
then h1:=timetostr(strtotime(M1)-strtotime(M2))
else begin
h1:='00:00:00';
manyana:=true;
end;
if not tarde
then h2:=timetostr(strtotime(T1)-strtotime(T2))
else begin
h2:='00:00:00';
tarde:=true;
end;

x:=timetostr((strtotime(h1)+strtotime(h2)));
if (not tarde) and (not manyana)
then begin
FFichaEmp.GEFichaje.Font.color := clnavy;


TFichajes.FieldByName('HTXT').AsString:=x;
mm:='';hh:='';
TFichajes.fieldbyname('Mayana').asstring:=h1;
TFichajes.fieldbyname('Tarde').asstring:=h2;

horas:=x;
for i:=1 to length(horas) do
begin
if Horas[i] <> ':'
then if i<3 then hh:=hh+Horas[i]
else if i>3 then
if i<6 then mm:=mm+Horas[i];
end;
hint:=strtoint(hh);
mint:=strtoint(mm);
TFichajes.Edit; { AL AÑADIR ESTA LINEA ME DA DESBORDAMIENTO}
TFichajes.FieldByName('Horas').AsInteger:= hint;
TFichajes.FieldByName('Minutos').AsInteger:=mint;

end
else begin
FFichaEmp.GEFichaje.Font.Color :=clred;
TFichajes.FieldByName('HTXT').AsString:=x;

mm:='';hh:='';
horas:=x;

for i:=1 to length(horas) do
begin
if Horas[i] <> ':'
then if i<3 then hh:=hh+Horas[i]
else if i>3 then
if i<6 then mm:=mm+Horas[i];
end;
hint:=strtoint(hh);
mint:=strtoint(mm);
TFichajes.Edit;
TFichajes.FieldByName('Horas').AsInteger:= hint;
TFichajes.FieldByName('Minutos').AsInteger:=mint;

end;

Como ves el codigo es muy rudimentario, lo siento pero soy novato...jeje

gracias por tu ayuda.

Adios.

Cita:
Empezado por guillotmarc
El mensaje de error te indica que tienes un desbordamiento de pila. ¿ Esta función es recursiva ?.

Vas a tener que poner algo de código, de la función que falla, y de como intentas actualizar el campo.

Saludos.
Responder Con Cita