Results 1 to 5 of 5

Thread: File Writing?

  1. #1
    Join Date
    Sep 2008
    Location
    My House
    Posts
    519
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default File Writing?

    I have this...

    Code:
    procedure Save_Usernames(str: String);
    var
      theFile: Integer;
      tempStr: String;
    begin
      if (FileExists(ScriptPath + 'Yaboe_Usernames.txt')) then
      begin
        theFile := OpenFile(ScriptPath + Name{This is a constant} + 'Yaboe_Usernames.txt', false);
        ReadFileString(theFile, tempStr, FileSize(theFile));
        CloseFile(theFile);
      end;
    
      theFile := RewriteFile(ScriptPath + 'Yaboe_Usernames.txt', false)
      WriteFileString(theFile, tempStr + str + #32#32#32#32#32 + FloatToStr(ext) + #13);
      CloseFile(theFile);
    end;
    And get this?

    Code:
    [Runtime Error] : Exception: Access violation at address 0077B189 in module 'scar.exe'. Read of address 00000003 in line 203 in script C:\Users\Brent\Desktop\SCAR 3.23 Beta\Yaboe Maker V2.1.2[Run Me].scar
    Whenever the file is already made?

  2. #2
    Join Date
    Oct 2006
    Location
    Ontario,Canada
    Posts
    1,718
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    what line gives the error?

  3. #3
    Join Date
    Sep 2008
    Location
    My House
    Posts
    519
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    This line

    Code:
    ReadFileString(theFile, tempStr, FileSize(theFile));
    Also Now when I try this instead...

    Code:
    program New;
    var
    v : string;
    
    procedure Save_Usernames(str: String);
    var
      theFile: Integer;
      tempStr: String;
    begin
      if (FileExists(ScriptPath + 'Yaboe_Usernames11.txt')) then
      begin
        theFile := OpenFile(ScriptPath + 'Yaboe_Usernames11.txt', false);
        ReadFileString(theFile, tempStr, FileSize(theFile));
        CloseFile(theFile);
      end;
    
      theFile := RewriteFile(ScriptPath + 'Yaboe_Usernames11.txt', false)
      WriteFileString(theFile, tempStr + str + #10#13);
      CloseFile(theFile);
    end;
    
    
    begin
         V := 'blahblahblahblah';
         Save_Usernames(V);
    end.
    I get this...

    Code:
    [Runtime Error] : Exception: Access violation at address 0077AE65 in module 'scar.exe'. Read of address FFFFFFFC in line 18 in script
    Line 18 is this...

    Code:
    WriteFileString(theFile, tempStr + str + #10#13);
    Last edited by Death12652; 05-18-2010 at 03:54 AM.

  4. #4
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    You're missing a CloseFile somewhere I think. I was getting that before. Sex should know. I'm asking him.

  5. #5
    Join Date
    Oct 2009
    Location
    Stockton, CA
    Posts
    2,040
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    No, he isn't missing a CloseFile.
    You are running it without saving the script; therefore ScriptPath is empty.
    Join the IRC! irc.rizon.net:6667/srl | SQLite (0.99rc3+) | SRL Doc | Simba Doc | Extra Simba Libraries (openSSL & sqlite3)
    Quote Originally Posted by #srl
    10:45 < Toter> daphil when can get sex anyday I want
    10:45 < Toter> he is always on #SRL
    "A programmer is just a tool which converts caffeine into code"

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
  •