Results 1 to 19 of 19

Thread: ReadINI help.

  1. #1
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default ReadINI help.

    I'm probably doing something really stupid, but I read over the documentation and it doesn't make much sense to me...

    The way I see it,
    Simba Code:
    ReadINI('MASTER', 'MasterStatus', ScriptPath + 'MasterINI.ini');
    should return
    Code:
    [MASTER]
    MasterStatus=IDLE
    As that's the KeyName in the INI file that I've specified.

    However when I writeLn it out, it returns nothing.
    What am I doing wrong?
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Bad™ before everyone gets laser pistols

  2. #2
    Join Date
    Oct 2013
    Location
    East Coast USA
    Posts
    770
    Mentioned
    61 Post(s)
    Quoted
    364 Post(s)

    Default

    Is your .ini file in the scripts folder?

    I ask because I noted last week that ScriptPath is NOT returning the script path, it is returning the SIMBA install folder.

  3. #3
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    Quote Originally Posted by bonsai View Post
    Is your .ini file in the scripts folder?

    I ask because I noted last week that ScriptPath is NOT returning the script path, it is returning the SIMBA install folder.
    It is in the script folder, yes but even after relocating my INI to C:\Simba, it still returns nothing.
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Bad™ before everyone gets laser pistols

  4. #4
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default

    Quote Originally Posted by bonsai View Post
    Is your .ini file in the scripts folder?

    I ask because I noted last week that ScriptPath is NOT returning the script path, it is returning the SIMBA install folder.
    For me too:

    Simba Code:
    writeln(ScriptPath);
    writeln(AppPath);

    Code:
    C:\Users\user\Desktop\Simba5\
    C:\Users\user\Desktop\Simba5\



    It is in the script folder, yes but even after relocating my INI to C:\Simba, it still returns nothing.
    No idea, it works for me:
    Simba Code:
    WriteINI('MASTER','MasterStatus','IDLE',AppPath+'initest.ini');
    s := ReadINI('s1','key1',AppPath+'initest.ini');
    writeln(s);
    Last edited by bg5; 11-17-2013 at 01:52 AM.

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

    Default

    Because you guys didnt save the script, hence it returns your simba.exe path as that is the location of the current instance of your unsaved script!
    If you save it to somewhere first, then it should return the correct path of the script:
    Code:
    C:\Users\riwu\Desktop\

    EDIT: i presume this is the content of your ini file?
    [MASTER]
    MasterStatus=IDLE
    It should return 'IDLE' then. Did you save the script to the same path as the ini file?
    Last edited by riwu; 11-17-2013 at 12:47 AM.

  6. #6
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    Because you guys didnt save the script, hence it returns your simba.exe path as that is the location of the current instance of your unsaved script!
    If you save it to somewhere first, then it should return the correct path of the script:
    Code:
    C:\Users\riwu\Desktop\

    EDIT: i presume this is the content of your ini file?

    It should return 'IDLE' then. Did you save the script to the same path as the ini file?
    I saved the script several times as I had developed some interface-detection functions previously.

    Yes that is the contents of my INI file.

    I already attempted reading from them both in the same dir, using ScriptPath, and then from the SIMBADIR, using AppPath. Neither worked.

    Quote Originally Posted by bg5 View Post
    For me too:

    Simba Code:
    writeln(ScriptPath);
    writeln(AppPath);

    Code:
    C:\Users\user\Desktop\Simba5\
    C:\Users\user\Desktop\Simba5\
    I think devs @Dgby714 might want to know about it.





    No idea, it works for me:
    Simba Code:
    WriteINI('MASTER','MasterStatus','IDLE',AppPath+'initest.ini');
    s := ReadINI('s1','key1',AppPath+'initest.ini');
    writeln(s);
    Why are you WriteINI'ing before you ReadINI? I'm just readINI'ing from a pre-existing INI.
    Also what is 's1' and 'key1'? Did you declare those previously in the script? I have the actual names of my section and key in the INI file.
    Last edited by KeepBotting; 11-17-2013 at 01:44 AM.
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Bad™ before everyone gets laser pistols

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

    Default

    Quote Originally Posted by KeepBotting View Post
    I saved the script several times as I had developed some interface-detection functions previously.

    Yes that is the contents of my INI file.

    I already attempted reading from them both in the same dir, using ScriptPath, and then from the SIMBADIR, using AppPath. Neither worked.
    Add this to ur current script and post the results:
    Simba Code:
    writeln(ScriptPath);
      writeln(getfiles(ScriptPath, 'ini'));

  8. #8
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default

    Quote Originally Posted by KeepBotting View Post


    Why are you WriteINI'ing before you ReadINI? I'm just readINI'ing from a pre-existing INI.
    Also what is 's1' and 'key1'? Did you declare those previously in the script? I have the actual names of my section and key in the INI file.
    Oh, sorry I messed my testing code a bit when pasting on forum. It should be:

    Simba Code:
    program new;
    var s:string;
    begin
    //WriteINI('MASTER','MasterStatus','IDLE',AppPath+'initest.ini');
    s := ReadINI('MASTER','MasterStatus',AppPath+'initest.ini');
    writeln(s);
    end.

    I used WriteINI to create file, instead of doing it manually. It doesn't matter, you can ignore this line.

  9. #9
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    Add this to ur current script and post the results:
    Simba Code:
    writeln(ScriptPath);
      writeln(getfiles(ScriptPath, 'ini'));
    Code:
    Compiled successfully in 1576 ms.
    C:\Users\KeepBotting\Dropbox\Scripts\Unreleased\rs3\iDuelist\
    [MasterINI.ini]
    -- Freeing gametabs bitmaps...
    Successfully executed.
    File[C:\Simba\Includes\SRL-6/logs/SRL log (16-11-13 at 09.39.49 PM).txt] has not been freed in the script, freeing it now.
    Quote Originally Posted by bg5 View Post
    Oh, sorry I messed my testing code a bit when pasting on forum. It should be:

    Simba Code:
    program new;
    var s:string;
    begin
    //WriteINI('MASTER','MasterStatus','IDLE',AppPath+'initest.ini');
    s := ReadINI('MASTER','MasterStatus',AppPath+'initest.ini');
    writeln(s);
    end.

    I used WriteINI to create file, instead of doing it manually. It doesn't matter, you can ignore this line.
    Oh alright, gotcha.
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Bad™ before everyone gets laser pistols

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

    Default

    ok post the entire script that you are running

  11. #11
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    ok post the entire script that you are running
    Simba Code:
    program iDuelist_SLAVE;
    {$DEFINE SMART}
    {$i srl-6/srl.simba}

    ///////////////////////////////////Start setting up the script here. Refer to the comments if you don't know what you're doing.
    ///////////////////////////////////
    /////       Start Setup     ///////
    ///////////////////////////////////
    ///////////////////////////////////Start setting up the script here. Refer to the comments if you don't know what you're doing.

    const
       (* player info *)
       playerNames  = ['slave']; //Put the slave's player name (or nickname, if you set one) here.
       playerFile   = 'default1'; //Put your playerfile's name here. Default is 'default'.
       desiredWorld = 0; //MAKE SURE MASTER & SLAVE ARE ON THE SAME WORLD LOL

       (* globals *)
       //Please fill out the globals on the MASTER script. The slave has no globals!

       (* options *)
       //Please fill out the options on the MASTER script. The slave has no options!

    ///////////////////////////////////Don't modify the script ANY FURTHER unless you know what you're doing. You could break stuff!
    ///////////////////////////////////
    /////       Stop Setup      ///////
    ///////////////////////////////////
    ///////////////////////////////////Don't modify the script ANY FURTHER unless you know what you're doing. You could break stuff!

    procedure getInfo;
    begin;
     writeLn('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
     writeLn('Welcome to iDuelist.SLAVE by KeepBotting!');
     writeLn('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
     writeLn('This script is 100% credits to KeepBotting, unless otherwise noted.');
     writeLn('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
    end;

    function challengeTypeScreen: boolean; //friendly or staked?
    var x, y:integer;
    begin
    result := FindColor(x, y, 1489692, 433, 425, 524, 438);
    //the text and its background on the 'send challenge' button
    end;

    function duelScreen: boolean; //duel interface where options are selected
    var x, y:integer;
    begin
    result := FindColor(x, y, 12378347, 406, 159, 552, 176);
    //opponent's username at top of interface
    end;

    function duelScreen_2: boolean; //duel interface where options are reviewed before duel starts
    var x, y:integer;
    begin
    result := FindColor(x, y, 5353701, 424, 280, 531, 292);
    //'During the duel...' text on the 2nd section of the interface
    end;

    function resultsScreen: boolean; //you won/lost screen
    var x, y:integer;
    begin
    result := FindColor(x, y, 6533359, 387, 434, 572, 451);
    //the text on the 'offer rematch' button (not background as it grabs half the interface)
    //no need to worry about relocating players as Jagex has kindly provided an auto-rematch button for us <3
    end;

    function isChallengePending: boolean;
    var x, y:integer;
    begin
    result := FindColor(x, y, 12926, 8, 535, 553, 611);
    //color of challenge text in chatbox
    end;

    function getSlaveStatus: string;
    begin
    //ini file-operations will go here
    end;

    procedure initScript; //adapted from bonsai's init procedure
    var i:integer;
    begin
       addOnTerminate('scriptTerminate');
       clearDebug();
       smartEnableDrawing := true;
       setupSrl();
       smartForceNewClient := true; //thanks olly
       players.setup(playerNames, playerFile);
       currentPlayer := 0;
       for i := 0 to high(players) do
       begin
          players[i].world := desiredWorld;
          players[i].isActive := true;
       end;
        while (players.getActive() > 0) do
       begin
          if (not isLoggedIn()) then
          begin
             if (not players[currentPlayer].login()) then break;
             exitSquealOfFortune();
          end;
       end;
    end;

    procedure waitForMaster;
    var value:string;
    begin
    clearDebug();
    writeLn('[MultiScriptHandler] : The slave script is ready.');
    writeLn('[MultiScriptHandler] : Please start the master script.');
    writeLn('[MultiScriptHandler] : The process will begin automatically once the master is logged in.');
    repeat
    writeLn('[MultiScriptHandler] : Please start the master script; waiting for communication...');
    wait(1000);
    until ReadINI('MASTER', 'MasterStatus', AppPath +'\MasterINI.ini');
    writeLn('[MultiScriptHandler] : Communiction established. Process beginning.');
    end;

    procedure test;
    begin
    writeln(ScriptPath);
    writeln(getfiles(ScriptPath, 'ini'));
    end;

    begin
    //waitForMaster;
    test;
    end.

    Not even sure it'll compile as it is, lol.
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Bad™ before everyone gets laser pistols

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

    Default

    Quote Originally Posted by KeepBotting View Post
    Simba Code:
    program iDuelist_SLAVE;
    {$DEFINE SMART}
    {$i srl-6/srl.simba}

    ///////////////////////////////////Start setting up the script here. Refer to the comments if you don't know what you're doing.
    ///////////////////////////////////
    /////       Start Setup     ///////
    ///////////////////////////////////
    ///////////////////////////////////Start setting up the script here. Refer to the comments if you don't know what you're doing.

    const
       (* player info *)
       playerNames  = ['slave']; //Put the slave's player name (or nickname, if you set one) here.
       playerFile   = 'default1'; //Put your playerfile's name here. Default is 'default'.
       desiredWorld = 0; //MAKE SURE MASTER & SLAVE ARE ON THE SAME WORLD LOL

       (* globals *)
       //Please fill out the globals on the MASTER script. The slave has no globals!

       (* options *)
       //Please fill out the options on the MASTER script. The slave has no options!

    ///////////////////////////////////Don't modify the script ANY FURTHER unless you know what you're doing. You could break stuff!
    ///////////////////////////////////
    /////       Stop Setup      ///////
    ///////////////////////////////////
    ///////////////////////////////////Don't modify the script ANY FURTHER unless you know what you're doing. You could break stuff!

    procedure getInfo;
    begin;
     writeLn('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
     writeLn('Welcome to iDuelist.SLAVE by KeepBotting!');
     writeLn('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
     writeLn('This script is 100% credits to KeepBotting, unless otherwise noted.');
     writeLn('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
    end;

    function challengeTypeScreen: boolean; //friendly or staked?
    var x, y:integer;
    begin
    result := FindColor(x, y, 1489692, 433, 425, 524, 438);
    //the text and its background on the 'send challenge' button
    end;

    function duelScreen: boolean; //duel interface where options are selected
    var x, y:integer;
    begin
    result := FindColor(x, y, 12378347, 406, 159, 552, 176);
    //opponent's username at top of interface
    end;

    function duelScreen_2: boolean; //duel interface where options are reviewed before duel starts
    var x, y:integer;
    begin
    result := FindColor(x, y, 5353701, 424, 280, 531, 292);
    //'During the duel...' text on the 2nd section of the interface
    end;

    function resultsScreen: boolean; //you won/lost screen
    var x, y:integer;
    begin
    result := FindColor(x, y, 6533359, 387, 434, 572, 451);
    //the text on the 'offer rematch' button (not background as it grabs half the interface)
    //no need to worry about relocating players as Jagex has kindly provided an auto-rematch button for us <3
    end;

    function isChallengePending: boolean;
    var x, y:integer;
    begin
    result := FindColor(x, y, 12926, 8, 535, 553, 611);
    //color of challenge text in chatbox
    end;

    function getSlaveStatus: string;
    begin
    //ini file-operations will go here
    end;

    procedure initScript; //adapted from bonsai's init procedure
    var i:integer;
    begin
       addOnTerminate('scriptTerminate');
       clearDebug();
       smartEnableDrawing := true;
       setupSrl();
       smartForceNewClient := true; //thanks olly
       players.setup(playerNames, playerFile);
       currentPlayer := 0;
       for i := 0 to high(players) do
       begin
          players[i].world := desiredWorld;
          players[i].isActive := true;
       end;
        while (players.getActive() > 0) do
       begin
          if (not isLoggedIn()) then
          begin
             if (not players[currentPlayer].login()) then break;
             exitSquealOfFortune();
          end;
       end;
    end;

    procedure waitForMaster;
    var value:string;
    begin
    clearDebug();
    writeLn('[MultiScriptHandler] : The slave script is ready.');
    writeLn('[MultiScriptHandler] : Please start the master script.');
    writeLn('[MultiScriptHandler] : The process will begin automatically once the master is logged in.');
    repeat
    writeLn('[MultiScriptHandler] : Please start the master script; waiting for communication...');
    wait(1000);
    until ReadINI('MASTER', 'MasterStatus', AppPath +'\MasterINI.ini');
    writeLn('[MultiScriptHandler] : Communiction established. Process beginning.');
    end;

    procedure test;
    begin
    writeln(ScriptPath);
    writeln(getfiles(ScriptPath, 'ini'));
    end;

    begin
    //waitForMaster;
    test;
    end.

    Not even sure it'll compile as it is, lol.
    Simba Code:
    until ReadINI('MASTER', 'MasterStatus', AppPath +'\MasterINI.ini');
    Uh it returns a string, not a boolean.
    Which statement were you expecting the string output from?
    Last edited by riwu; 11-17-2013 at 05:00 AM.

  13. #13
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    Simba Code:
    until ReadINI('MASTER', 'MasterStatus', AppPath +'\MasterINI.ini');
    Uh it returns a string, not a boolean.
    Which statement were you expecting the string output from?
    Oh that string I declared was left over from an older version of that procedure, it's not being used anymore.
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Bad™ before everyone gets laser pistols

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

    Default

    Quote Originally Posted by KeepBotting View Post
    Oh that string I declared was left over from an older version of that procedure, it's not being used anymore.
    Which string are u referring to?
    However when I writeLn it out, it returns nothing.
    at which line did you do this?

  15. #15
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    Which string are u referring to?

    at which line did you do this?
    The string I declared at the top of waitForMaster, which are you referring to?

    And it's not there anymore but I had done

    Code:
    writeLn(ReadINI('MASTER', 'MasterStatus', AppPath +'\MasterINI.ini'));
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Bad™ before everyone gets laser pistols

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

    Default

    Quote Originally Posted by KeepBotting View Post
    The string I declared at the top of waitForMaster, which are you referring to?

    And it's not there anymore but I had done

    Code:
    writeLn(ReadINI('MASTER', 'MasterStatus', AppPath +'\MasterINI.ini'));
    Try ScriptPath then, since your previous result shows that you have the file there:
    C:\Users\KeepBotting\Dropbox\Scripts\Unreleased\rs 3\iDuelist\
    [MasterINI.ini]

  17. #17
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    Try ScriptPath then, since your previous result shows that you have the file there:
    That's the first thing I tried. It didn't work, which is why I posted this thread.
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Bad™ before everyone gets laser pistols

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

    Default

    Quote Originally Posted by KeepBotting View Post
    That's the first thing I tried. It didn't work, which is why I posted this thread.
    Add me on skype riwu0730, i can tv u. I'm curious now as to what the problem might be.

  19. #19
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    Add me on skype riwu0730, i can tv u. I'm curious now as to what the problem might be.
    WAIT A MINUTE
    I just realized what you'd said about it returning a string.

    I was going through the whole process with the assumption that ReadINI returned true/false if it finds a valus in the section-key specified.

    But it doesn't, it returns the actual string value of the key specified.

    I was attempting to call it as a boolean, which makes sense why it never returned anything because it just didn't. It returns a string.

    example of what I was doing wrong:
    Simba Code:
    repeat
    //waitloop
    until ReadINI('MASTER', 'MasterStatus', AppPath +'\MasterINI.ini');

    what I'm now doing right:
    Simba Code:
    repeat
    writeLn('[MultiScriptHandler] : Please start the master script; waiting for communication...');
    wait(1000);
    value := ReadINI('MASTER', 'MasterStatus', AppPath +'\MasterINI.ini');
    until value := 'IDLE';
    writeLn('[MultiScriptHandler] : Communiction established. Process beginning.');

    Thanks for you help, lol. I wouldn't have figured it out if you hadn't mentioned that about it returning a string and it still took me another little time to get it through my head.
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Bad™ before everyone gets laser pistols

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
  •