自定义function 如下:function fb(MinInt:integer;MaxInt:integer;CountInt:integer):boolean;
  var  i:integer;
  begin
    if fileopen(filename,fmOpenWrite)>0 then
      begin
       for i:=0 to countint-1  do
          WriteInteger(MinInt);
        for i:=0 to countint-1  do
          WriteInteger(MaxInt);
        fb:=true;
       end
    else
       fb:=false;  end;
每行写入一个数字,将minint写入countint次,将maxintt写入countint次,返回一个boolean表示写入是否成功

解决方案 »

  1.   

    procedure WriteLog(myLog:string);
    const
      sLogDir = '\Log\';
    var
      strFile: String;
      strTemp: WideString;
      tFile: TextFile;
    begin
      strFile := ExtractFileDir(Application.ExeName)+sLogDir+FormatDateTime('yyyymmdd',Date())+'.txt';
      AssignFile(tFile,strFile);  if not DirectoryExists(sLogDir) then
        if not CreateDir(sLogDir) then
        raise Exception.Create('Cannot create '+sLogDir);  try
        if FileExists(strFile) then
           Append(tFile)
        else
           ReWrite(tFile);
        strTemp := Format('%s',
                       [Trim(myLog)]);
        Writeln(tFile,strTemp);
      finally
        CloseFile(tFile);
      end;
    end;