SRL Archive - OSR Help

ReadINI help.


KeepBotting

2013-11-15 07:55:00

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,
ReadINI('MASTER', 'MasterStatus', ScriptPath + 'MasterINI.ini');
should return
[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?

bonsai

2013-11-15 08:25:54

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.

KeepBotting

2013-11-15 17:01:37

From: bonsai
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.

bg5

2013-11-16 15:07:36

From: bonsai
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:


writeln(ScriptPath);
writeln(AppPath);

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:
WriteINI('MASTER','MasterStatus','IDLE',AppPath+'initest.ini');
s := ReadINI('s1','key1',AppPath+'initest.ini');
writeln(s);

riwu

2013-11-16 19:38:51

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:

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?

KeepBotting

2013-11-16 20:41:42

From: riwu
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:

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.

From: bg5
For me too:


writeln(ScriptPath);
writeln(AppPath);

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:
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.

riwu

2013-11-16 20:47:23

From: KeepBotting
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:

writeln(ScriptPath);
writeln(getfiles(ScriptPath, 'ini'));

bg5

2013-11-16 20:52:02

From: KeepBotting



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:

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.

KeepBotting

2013-11-16 21:39:31

From: riwu
Add this to ur current script and post the results:

writeln(ScriptPath);
writeln(getfiles(ScriptPath, 'ini'));
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.
From: bg5
Oh, sorry I messed my testing code a bit when pasting on forum. It should be:

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.

riwu

2013-11-16 22:20:22

ok post the entire script that you are running

KeepBotting

2013-11-16 22:40:03

From: riwu
ok post the entire script that you are running

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.

riwu

2013-11-16 23:48:30

From: KeepBotting
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.


until ReadINI('MASTER', 'MasterStatus', AppPath +'\MasterINI.ini');
Uh it returns a string, not a boolean.
Which statement were you expecting the string output from?

KeepBotting

2013-11-17 08:44:50

From: riwu

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.

riwu

2013-11-17 09:03:34

From: KeepBotting
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?

KeepBotting

2013-11-17 09:42:40

From: riwu
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

writeLn(ReadINI('MASTER', 'MasterStatus', AppPath +'\MasterINI.ini'));

riwu

2013-11-17 18:06:02

From: KeepBotting
The string I declared at the top of waitForMaster, which are you referring to?

And it's not there anymore but I had done

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\rs3\iDuelist\
[MasterINI.ini]

KeepBotting

2013-11-17 19:43:13

From: riwu
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.

riwu

2013-11-18 07:27:56

From: KeepBotting
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.

KeepBotting

2013-11-18 08:05:03

From: riwu
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:

repeat
//waitloop
until ReadINI('MASTER', 'MasterStatus', AppPath +'\MasterINI.ini');

what I'm now doing right:

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.