Results 1 to 6 of 6

Thread: Save Setting and StrToInt Runtime Error- Serious Question No Joke.

  1. #1
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Save Setting and StrToInt Runtime Error- Serious Question No Joke.

    Code:
    program StupidLoophole;
    var
    TotalScriptRUNS : Integer;
    procedure StartupScript; //First Main procedure used in script, doesn't repeat.
    begin
      TotalScriptRUNS := StrToInt(LoadSetting('TheSetting', 'TotalScriptRUNS'));
      TotalScriptRUNS := TotalScriptRUNS + 1
      SaveSetting('TheSetting' ,'TotalScriptRUNS', IntToStr(TotalScriptRUNS));
    end;
    
    begin
    StartUpScript;
    Writeln('You have run this loop hole script ' + IntToStr(TotalScriptRuns)+ ' time(s)');
    end.
    Try to run this, see my problem.

    Any ideas?

  2. #2
    Join Date
    Feb 2006
    Location
    Under a rock.
    Posts
    1,351
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    The first time you run it LoadSetting will return null. Null is not a number.. Try this:
    Code:
    program StupidLoophole;
    var
    TotalScriptRUNS : Integer;
    procedure StartupScript; //First Main procedure used in script, doesn't repeat.
    begin
      try
        TotalScriptRUNS := StrToInt(LoadSetting('TheSetting', 'TotalScriptRUNS'));
      except
        TotalScriptRuns := 0;
      end;
      TotalScriptRUNS := TotalScriptRUNS + 1
      SaveSetting('TheSetting' ,'TotalScriptRUNS', IntToStr(TotalScriptRUNS));
    end;
    
    begin
    StartUpScript;
    Writeln('You have run this loop hole script ' + IntToStr(TotalScriptRuns)+ ' time(s)');
    end.
    SRL Developer
    ◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘

  3. #3
    Join Date
    Feb 2006
    Location
    London, England
    Posts
    2,045
    Mentioned
    2 Post(s)
    Quoted
    0 Post(s)

    Default

    StrToIntDef(LoadSetting('TheSetting', 'TotalScriptRUNS'), 0);
    SRL Wiki | SRL Rules | SRL Stats
    Ultimate SCAR Scripting Tutorial | Starblaster100's Auth System | Join the official SRL IRC now!


    Help Keep SRL Alive! Please disable Advert Blockers on SRL! Help Keep SRL Alive!


  4. #4
    Join Date
    Jun 2006
    Posts
    3,861
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Umm I've always wondered the difference between StrToInt and StrToIntDef. I'll ask here instead of creating a new topic

  5. #5
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Starblaster100 View Post
    StrToIntDef(LoadSetting('TheSetting', 'TotalScriptRUNS'), 0);

    Thank you very much Star!



    Edit: And CheeseHunk

  6. #6
    Join Date
    Feb 2006
    Location
    London, England
    Posts
    2,045
    Mentioned
    2 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by bullzeye95 View Post
    Umm I've always wondered the difference between StrToInt and StrToIntDef. I'll ask here instead of creating a new topic
    Def stands for default. if the string cannot be turned into an integer, it will set the variable as the 'default' number you put.
    SRL Wiki | SRL Rules | SRL Stats
    Ultimate SCAR Scripting Tutorial | Starblaster100's Auth System | Join the official SRL IRC now!


    Help Keep SRL Alive! Please disable Advert Blockers on SRL! Help Keep SRL Alive!


Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [Runtime Error] : Exception: buffer error
    By GasMan in forum OSR Help
    Replies: 11
    Last Post: 05-13-2007, 02:07 PM
  2. StrToInt(Edit1.Text);
    By Thick As Blood in forum OSR Help
    Replies: 7
    Last Post: 03-09-2007, 12:57 PM

Posting Permissions

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