Results 1 to 3 of 3

Thread: SaveDataToFile

  1. #1
    Join Date
    Feb 2012
    Location
    DON'T PM ME ASKING FOR STUFF
    Posts
    2,170
    Mentioned
    38 Post(s)
    Quoted
    423 Post(s)

    Default SaveDataToFile

    Hey guys,

    Just wondering if you could help me out. Don't want to post the whole script so heres the necessary snippets:

    Code:
    procedure SaveDataToFile(file,text:string);
    var
      SaveFile, thefile: Integer;
      Str: string;
    begin
      if FileExists(file) then
      begin
        thefile := OpenFile(file,true);
        ReadFileString(thefile,str, FileSize(thefile));
        CloseFile(thefile);
      end;
      SaveFile := RewriteFile(file, False);
      if str = '' then
        WriteFileString(SaveFile,text)
      else
        begin
          WriteFileString(SaveFile,str + chr(13) + text);
        end;
      Writeln('Saved to: '+file);
      CloseFile(SaveFile);
    end;
    Code:
    SaveDataToFile('C:\Simba\Scripts\Logs', mailfirstname + IntToStr(k) + mailextension);
    Whenever I run it, this is the error I get:

    ReWriteFile - Exception. Could not create file: C:\Simba\Scripts\Logs
    Error: Exception: Invalid FileNum passed: -1 at line 84
    Not sure why its trying to ReWrite the file straight off.. any suggestions?

    Thanks guys

  2. #2
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Your argument:
    Simba Code:
    SaveDataToFile('C:\Simba\Scripts\Logs', mailfirstname + IntToStr(k) + mailextension);
    The path must specify a file name
    eg. C:\Simba\Scripts\Logs\abc.txt.

  3. #3
    Join Date
    Feb 2012
    Location
    DON'T PM ME ASKING FOR STUFF
    Posts
    2,170
    Mentioned
    38 Post(s)
    Quoted
    423 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    Your argument:
    Simba Code:
    SaveDataToFile('C:\Simba\Scripts\Logs', mailfirstname + IntToStr(k) + mailextension);
    The path must specify a file name
    eg. C:\Simba\Scripts\Logs\abc.txt.
    tyvm

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •