Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 21-02-2007
Avatar de nlsgarcia
[nlsgarcia] nlsgarcia is offline
Miembro Premium
 
Registrado: feb 2007
Ubicación: Caracas, Venezuela
Posts: 2.206
Poder: 21
nlsgarcia Tiene un aura espectacularnlsgarcia Tiene un aura espectacular
Una Pregunta Teórica sobre Archivos UDT

Hola:

El siguiente programa funciona correctamente:

Código Delphi [-]
 
program TestFile;
{$APPTYPE CONSOLE}
uses
  SysUtils, StrUtils;
Type
TPrnCmd = Record
   ProcPrnCmd : array [0..40] of char;
   DatePrnCmd : array [0..12] of char;
   TimePrnCmd : array [0..12] of char;
   Status : array [0..30] of char;
   CRLF : array [0..1] of char;
end;
var
   i : integer;
   RegPrnCmd : TPrnCmd;
function LogPrnCmd(LogFile, ProcPrnCmd, StatusProc : String) : Boolean;
var
   i : integer;
   f: File of TPrnCmd;
   // RegPrnCmd : TPrnCmd;
   DateProc : String;
begin
   LogFile := GetCurrentDir + '\' + LogFile;
   AssignFile(f, LogFile);
   FileMode := fmOpenWrite ;
   if FileExists(LogFile) then
      Reset(f)
   else
      Rewrite(f);
   DateProc := FormatDateTime('dd/mm/yyyy',Date);
   StrPCopy(RegPrnCmd.ProcPrnCmd,ProcPrnCmd);
   StrPCopy(RegPrnCmd.DatePrnCmd,MidStr(DateProc,7,4) + '-' + MidStr(DateProc,4,2) + '-' + MidStr(DateProc,1,2));
   StrPCopy(RegPrnCmd.TimePrnCmd,FormatDateTime('hh:mm:ss',Time));
   StrPCopy(RegPrnCmd.Status,StatusProc);
   StrPCopy(RegPrnCmd.CRLF,chr(13)+chr(10));

   Seek(f, FileSize(f));
   Write(f,RegPrnCmd);
   CloseFile(f);
end;
begin
   for i := 1 to 10 do
      LogPrnCmd('TestFile.txt','Proc'+IntToStr(i),'Status'+IntToStr(i));
end.

La estructura UDT RegPrnCmd : TPrnCmd, esta definida a nivel global, y esta en la function LogPrnCmd, pero como comentario. Si se comenta la que esta a nivel global (RegPrnCmd) y se usa a nivel local, eliminando los carácteres de comentario, el programa da el error: "Project TestFile.exe raised exception class EInOutError with message I/O error 6. Process Stopped. Use Step or Run to continue.

La pregunta es: ¿Por que funciona si la declaración de RegPrnCmd, es a nivel global y falla si es declarada a nivel local?

Como dije anteriormente es una pregunta teórica, el programa ya funciona pero me gustaría aclarar la duda.

Gracias de antemano por toda la colaboración prestada.
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Pregunta Sobre el uso del DBGrid MARYLOSO Conexión con bases de datos 5 14-07-2005 17:19:03
Pregunta sobre BDE JorgeBec Conexión con bases de datos 1 18-03-2005 15:53:02
Pregunta sobre .net VolaRe .NET 10 14-04-2004 22:09:50
pregunta sobre Ms Sql ssaavedra MS SQL Server 1 09-01-2004 15:35:51
Pregunta sobre SplashScreen DarkByte Varios 2 14-09-2003 20:33:48


La franja horaria es GMT +2. Ahora son las 12:20:04.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi