Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2007-12

Local variable X does not seem to be initialized as a "TextFile" value

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

TOUZEAU DAVID

Dear

I have many warning like
(966,12) Hint: Local variable "X" does not seem to be initialized that X is a TextFile

I understand that only X is initialized when assign() it

How to prevent this warning ?? How to initialize a TextFile value...

example

procedure Xseen(line:string);
 var
 zDate:string;
 myFile : TextFile;
 xText:string;
 TargetPath:string;
 BEGIN
        xText:='';
        writeln('log::' + line);
        TargetPath:='/var/log';
        zDate:=DateToStr(Date)+ chr(32)+TimeToStr(Time);
        xText:=zDate + ' ' + line;
        TRY
           AssignFile(myFile, TargetPath);
           if FileExists(TargetPath) then Append(myFile);
           if not FileExists(TargetPath) then ReWrite(myFile);
            writeln(myFile, line);
            CloseFile(myFile);
        EXCEPT
          END;
 END;
David Touzeau -------------------------- Linux Ubuntu 7.04 feisty FreePascal-Lazarus,perl,delphi,php artica for postfix management console (http://www.artica.fr) icq:160018849

Reply by email

Jonas Maebe
to TOUZEAU DAVID
TOUZEAU DAVID wrote 7 lines
I have many warning like (966,12) Hint: Local variable "X" does not seem to be initialized that X is a TextFile I understand that only X is initialized when assign() it How to prevent this warning ??

Upgrade to FPC 2.2.0 or later.

Jonas

Reply by email