SRL Archive - Help

Type mismatch


rj

2013-02-09 12:37:59

Hello, when i try to run this:

Procedure GetPositions;
Begin
Begin
if box1count >= 70 and box1countI >= 10 then
//box1countI >= 10 then
Begin
box1countR := 'Iron'
End;
if box1Count >= 70 and box1countI <= 10 then
Begin
box1countR := 'Rock'
End;
if box1Count =< 70 and box1countI =< 10 then
Begin
box1countR := 'Nothing'
End;
End;
End;

I get a error:

[Error] C:\Simba\Scripts\GetRocks.simba(18:45): Type mismatch at line 17
Compiling failed.

Line 17:
if box1count >= 70 and box1countI >= 10 then


Here is the whole script if you need:

Program ShowOres;
{$DEFINE SMART}
{$i srl/srl.simba}
{$i sps/sps.simba}
{$I SRL/SRL/misc/SmartGraphics.simba}
Const
COLORROCK = 5988191;
COLORORE = 1910337;
TOL = 15;
var
box1count,box2count,box3count,box4count,box5count,box6count:Integer;
box1countI,box2countI,box3countI,box4countI,box5countI,box6countI:Integer;
box1countR,box2CountR,box3CountR,box4CountR,box5CountR,box6CountR:String;
Procedure GetPositions;
Begin
Begin
if box1count >= 70 and box1countI >= 10 then
//box1countI >= 10 then
Begin
box1countR := 'Iron'
End;
if box1Count >= 70 and box1countI <= 10 then
Begin
box1countR := 'Rock'
End;
if box1Count =< 70 and box1countI =< 10 then
Begin
box1countR := 'Nothing'
End;
End;
End;
Procedure GetRocks;
Begin
box1count := CountColorTolerance(COLORROCK, 215, 182-50, 247, 213-50, TOL);
box2count := CountColorTolerance(COLORROCK, 247, 182-50, 279, 213-50, TOL);
box3count := CountColorTolerance(COLORROCK, 279, 182-50, 309, 213-50, TOL);
box4count := CountColorTolerance(COLORROCK, 215, 213-50, 247, 244-50, TOL);
box5count := CountColorTolerance(COLORROCK, 247, 213-50, 279, 244-50, TOL);
box6count := CountColorTolerance(COLORROCK, 279, 213-50, 309, 244-50, TOL);

box1countI := CountColorTolerance(COLORORE, 215, 182-50, 247, 213-50, TOL);
box2countI := CountColorTolerance(COLORORE, 247, 182-50, 279, 213-50, TOL);
box3countI := CountColorTolerance(COLORORE, 279, 182-50, 309, 213-50, TOL);
box4countI := CountColorTolerance(COLORORE, 215, 213-50, 247, 244-50, TOL);
box5countI := CountColorTolerance(COLORORE, 247, 213-50, 279, 244-50, TOL);
box6countI := CountColorTolerance(COLORORE, 279, 213-50, 309, 244-50, TOL);
{Writeln('BOX1:' + IntToStr(box1count) + '');
Writeln('BOX2:' + IntToStr(box2count) + '');
Writeln('BOX3:' + IntToStr(box3count) + '');
Writeln('BOX4:' + IntToStr(box4count) + '');
Writeln('BOX5:' + IntToStr(box5count) + '');
Writeln('BOX6:' + IntToStr(box6count) + '');

Writeln('BOX1:' + IntToStr(box1countI) + '');
Writeln('BOX2:' + IntToStr(box2countI) + '');
Writeln('BOX3:' + IntToStr(box3countI) + '');
Writeln('BOX4:' + IntToStr(box4countI) + '');
Writeln('BOX5:' + IntToStr(box5countI) + '');
Writeln('BOX6:' + IntToStr(box6countI) + ''); }
End;
Begin
SetupSRL;
ActivateClient;
GetRocks;
End.

King

2013-02-09 12:42:17

Program ShowOres;
{$DEFINE SMART8}
{$i srl/srl.simba}
{$i sps/sps.simba}
{$I SRL/SRL/misc/SmartGraphics.simba}
Const
COLORROCK = 5988191;
COLORORE = 1910337;
TOL = 15;
var
box1count,box2count,box3count,box4count,box5count,box6count:Integer;
box1countI,box2countI,box3countI,box4countI,box5countI,box6countI:Integer;
box1countR,box2CountR,box3CountR,box4CountR,box5CountR,box6CountR:String;
Procedure GetPositions;
Begin
Begin
if (box1count >= 70) and (box1countI >= 10) then //You need to wrap paranetheses around values that use <= ect.
//(box1countI >= 10) then // Another Example is using (TimeFromMark(x) >= 20000)
Begin
box1countR := 'Iron'
End;
if (box1Count >= 70) and (box1countI <= 10) then
Begin
box1countR := 'Rock'
End;
if (box1Count <= 70) and (box1countI <= 10) //then Greater than Less than must come first else it produces a Syntax error :P
Begin
box1countR := 'Nothing'
End;
End;
End;
Procedure GetRocks;
Begin
box1count := CountColorTolerance(COLORROCK, 215, 182-50, 247, 213-50, TOL);
box2count := CountColorTolerance(COLORROCK, 247, 182-50, 279, 213-50, TOL);
box3count := CountColorTolerance(COLORROCK, 279, 182-50, 309, 213-50, TOL);
box4count := CountColorTolerance(COLORROCK, 215, 213-50, 247, 244-50, TOL);
box5count := CountColorTolerance(COLORROCK, 247, 213-50, 279, 244-50, TOL);
box6count := CountColorTolerance(COLORROCK, 279, 213-50, 309, 244-50, TOL);

box1countI := CountColorTolerance(COLORORE, 215, 182-50, 247, 213-50, TOL);
box2countI := CountColorTolerance(COLORORE, 247, 182-50, 279, 213-50, TOL);
box3countI := CountColorTolerance(COLORORE, 279, 182-50, 309, 213-50, TOL);
box4countI := CountColorTolerance(COLORORE, 215, 213-50, 247, 244-50, TOL);
box5countI := CountColorTolerance(COLORORE, 247, 213-50, 279, 244-50, TOL);
box6countI := CountColorTolerance(COLORORE, 279, 213-50, 309, 244-50, TOL);
{Writeln('BOX1:' + IntToStr(box1count) + '');
Writeln('BOX2:' + IntToStr(box2count) + '');
Writeln('BOX3:' + IntToStr(box3count) + '');
Writeln('BOX4:' + IntToStr(box4count) + '');
Writeln('BOX5:' + IntToStr(box5count) + '');
Writeln('BOX6:' + IntToStr(box6count) + '');

Writeln('BOX1:' + IntToStr(box1countI) + '');
Writeln('BOX2:' + IntToStr(box2countI) + '');
Writeln('BOX3:' + IntToStr(box3countI) + '');
Writeln('BOX4:' + IntToStr(box4countI) + '');
Writeln('BOX5:' + IntToStr(box5countI) + '');
Writeln('BOX6:' + IntToStr(box6countI) + ''); }
End;
Begin
SetupSRL;
ActivateClient;
GetRocks;
End.
'

Fixed with explanations, code compiles fine now :P

rj

2013-02-09 12:45:34

From: SRLKing
Program ShowOres;
{$DEFINE SMART8}
{$i srl/srl.simba}
{$i sps/sps.simba}
{$I SRL/SRL/misc/SmartGraphics.simba}
Const
COLORROCK = 5988191;
COLORORE = 1910337;
TOL = 15;
var
box1count,box2count,box3count,box4count,box5count,box6count:Integer;
box1countI,box2countI,box3countI,box4countI,box5countI,box6countI:Integer;
box1countR,box2CountR,box3CountR,box4CountR,box5CountR,box6CountR:String;
Procedure GetPositions;
Begin
Begin
if (box1count >= 70) and (box1countI >= 10) then //You need to wrap paranetheses around values that use <= ect.
//(box1countI >= 10) then // Another Example is using (TimeFromMark(x) >= 20000)
Begin
box1countR := 'Iron'
End;
if (box1Count >= 70) and (box1countI <= 10) then
Begin
box1countR := 'Rock'
End;
if (box1Count <= 70) and (box1countI <= 10) //then Greater than Less than must come first else it produces a Syntax error :P
Begin
box1countR := 'Nothing'
End;
End;
End;
Procedure GetRocks;
Begin
box1count := CountColorTolerance(COLORROCK, 215, 182-50, 247, 213-50, TOL);
box2count := CountColorTolerance(COLORROCK, 247, 182-50, 279, 213-50, TOL);
box3count := CountColorTolerance(COLORROCK, 279, 182-50, 309, 213-50, TOL);
box4count := CountColorTolerance(COLORROCK, 215, 213-50, 247, 244-50, TOL);
box5count := CountColorTolerance(COLORROCK, 247, 213-50, 279, 244-50, TOL);
box6count := CountColorTolerance(COLORROCK, 279, 213-50, 309, 244-50, TOL);

box1countI := CountColorTolerance(COLORORE, 215, 182-50, 247, 213-50, TOL);
box2countI := CountColorTolerance(COLORORE, 247, 182-50, 279, 213-50, TOL);
box3countI := CountColorTolerance(COLORORE, 279, 182-50, 309, 213-50, TOL);
box4countI := CountColorTolerance(COLORORE, 215, 213-50, 247, 244-50, TOL);
box5countI := CountColorTolerance(COLORORE, 247, 213-50, 279, 244-50, TOL);
box6countI := CountColorTolerance(COLORORE, 279, 213-50, 309, 244-50, TOL);
{Writeln('BOX1:' + IntToStr(box1count) + '');
Writeln('BOX2:' + IntToStr(box2count) + '');
Writeln('BOX3:' + IntToStr(box3count) + '');
Writeln('BOX4:' + IntToStr(box4count) + '');
Writeln('BOX5:' + IntToStr(box5count) + '');
Writeln('BOX6:' + IntToStr(box6count) + '');

Writeln('BOX1:' + IntToStr(box1countI) + '');
Writeln('BOX2:' + IntToStr(box2countI) + '');
Writeln('BOX3:' + IntToStr(box3countI) + '');
Writeln('BOX4:' + IntToStr(box4countI) + '');
Writeln('BOX5:' + IntToStr(box5countI) + '');
Writeln('BOX6:' + IntToStr(box6countI) + ''); }
End;
Begin
SetupSRL;
ActivateClient;
GetRocks;
End.
'

Fixed with explanations, code compiles fine now :P


Thanks! Lets test this baby out I'll post results when I finish but its going to look something like:


|Nothing|Iron|Nothing|
Iron|Player|Rock|
|Nothing|Nothing|Nothing|

King

2013-02-09 12:47:51

From: rjj95
Thanks! Lets test this baby out I'll post results when I finish but its going to look something like:


|Nothing|Iron|Nothing|
Iron|Player|Rock|
|Nothing|Nothing|Nothing|



:spot: Np! Let me know how it goes!

rj

2013-02-09 12:52:11

It's not displaying all the results:

||Iron||
|Rock||Iron|





did I do something wrong?


Program ShowOres;
{$DEFINE SMART}
{$i srl/srl.simba}
{$i sps/sps.simba}
{$I SRL/SRL/misc/SmartGraphics.simba}
Const
COLORROCK = 5988191;
COLORORE = 1910337;
TOL = 15;
var
box1count,box2count,box3count,box4count,box5count,box6count:Integer;
box1countI,box2countI,box3countI,box4countI,box5countI,box6countI:Integer;
box1countR,box2CountR,box3CountR,box4CountR,box5CountR,box6CountR:String;
Procedure WriteRocks;
Begin
Writeln('|' + box1countR +'|' + box2countR + '|' + box3countR + '|');
Writeln('|' + box4countR +'|' + box5countR + '|' + box6countR + '|');
End;
Procedure GetPositions;
Begin
{
Box 1 Counts
}
Begin
if (box1count >= 70) and (box1countI >= 10) then //You need to wrap paranetheses around values that use <= ect.
//box1countI >= 10 then
Begin
box1countR := 'Iron'
End;
if (box1Count >= 70) and (box1countI <= 10) then
Begin
box1countR := 'Rock'
End;
if (box1Count <= 70) and (box1countI <= 10) then
//then Greater than Less than must come first else it produces a Syntax error :P
Begin
box1countR := 'Nothing'
End;
End;
{
Box 2 Counts
}
Begin
if (box2count >= 70) and (box2countI >= 10) then

Begin
box2countR := 'Iron'
End;
if (box2Count >= 70) and (box2countI <= 10) then
Begin
box2countR := 'Rock'
End;
if (box2Count <= 70) and (box2countI <= 10) then

Begin
box2countR := 'Nothing'
End;
End;
{
Box 3 Counts
}
Begin
if (box3count >= 70) and (box3countI >= 10) then

Begin
box3countR := 'Iron'
End;
if (box3Count >= 70) and (box3countI <= 10) then
Begin
box3countR := 'Rock'
End;
if (box3Count <= 70) and (box3countI <= 10) then

Begin
box3countR := 'Nothing'
End;
End;
{
Box 4 Counts
}
Begin
if (box4count >= 70) and (box4countI >= 10) then

Begin
box4countR := 'Iron'
End;
if (box4Count >= 70) and (box4countI <= 10) then
Begin
box4countR := 'Rock'
End;
if (box4Count <= 70) and (box4countI <= 10) then

Begin
box4countR := 'Nothing'
End;
End;
{
Box 5 Counts
}
Begin
if (box5count >= 70) and (box5countI >= 10) then

Begin
box5countR := 'Iron'
End;
if (box5Count >= 70) and (box5countI <= 10) then
Begin
box5countR := 'Rock'
End;
if (box5Count <= 70) and (box5countI <= 10) then

Begin
box5countR := 'Nothing'
End;
End;
{
Box 6 Counts
}
Begin
if (box6count >= 70) and (box6countI >= 10) then

Begin
box6countR := 'Iron'
End;
if (box6Count >= 70) and (box6countI <= 10) then
Begin
box6countR := 'Rock'
End;
if (box6Count <= 70) and (box6countI <= 10) then

Begin
box6countR := 'Nothing'
End;
End;

End;
Procedure GetRocks;
Begin
box1count := CountColorTolerance(COLORROCK, 215, 182-50, 247, 213-50, TOL);
box2count := CountColorTolerance(COLORROCK, 247, 182-50, 279, 213-50, TOL);
box3count := CountColorTolerance(COLORROCK, 279, 182-50, 309, 213-50, TOL);
box4count := CountColorTolerance(COLORROCK, 215, 213-50, 247, 244-50, TOL);
box5count := CountColorTolerance(COLORROCK, 247, 213-50, 279, 244-50, TOL);
box6count := CountColorTolerance(COLORROCK, 279, 213-50, 309, 244-50, TOL);

box1countI := CountColorTolerance(COLORORE, 215, 182-50, 247, 213-50, TOL);
box2countI := CountColorTolerance(COLORORE, 247, 182-50, 279, 213-50, TOL);
box3countI := CountColorTolerance(COLORORE, 279, 182-50, 309, 213-50, TOL);
box4countI := CountColorTolerance(COLORORE, 215, 213-50, 247, 244-50, TOL);
box5countI := CountColorTolerance(COLORORE, 247, 213-50, 279, 244-50, TOL);
box6countI := CountColorTolerance(COLORORE, 279, 213-50, 309, 244-50, TOL);
{Writeln('BOX1:' + IntToStr(box1count) + '');
Writeln('BOX2:' + IntToStr(box2count) + '');
Writeln('BOX3:' + IntToStr(box3count) + '');
Writeln('BOX4:' + IntToStr(box4count) + '');
Writeln('BOX5:' + IntToStr(box5count) + '');
Writeln('BOX6:' + IntToStr(box6count) + '');

Writeln('BOX1:' + IntToStr(box1countI) + '');
Writeln('BOX2:' + IntToStr(box2countI) + '');
Writeln('BOX3:' + IntToStr(box3countI) + '');
Writeln('BOX4:' + IntToStr(box4countI) + '');
Writeln('BOX5:' + IntToStr(box5countI) + '');
Writeln('BOX6:' + IntToStr(box6countI) + ''); }
End;
Begin
SetupSRL;
ActivateClient;
GetRocks;
GetPositions;
WriteRocks;
End.


EDIT: When i go to login screen I can manage to get these results:

Rock results
BOX1:0
BOX2:0
BOX3:0
BOX4:0
BOX5:0
BOX6:0
Iron Results
BOX1:0
BOX2:0
BOX3:0
BOX4:0
BOX5:0
BOX6:0
|Nothing|Nothing|Nothing|
|Nothing|Nothing|Nothing|

But when I login I get:

Rock results
BOX1:20
BOX2:92
BOX3:31
BOX4:99
BOX5:11
BOX6:136
Iron Results
BOX1:206
BOX2:64
BOX3:93
BOX4:23
BOX5:23
BOX6:78
||Iron||
|Iron||Iron|

Kasi

2013-02-09 13:01:56

try putting a ";" after your strings, pure guess.
Edit : if that doesn't work maybe it isn't entering your statements

rj

2013-02-09 13:18:22

I set 'nothing' as defualt result works fine, now I just gotta work on rock detection the results are inaccurate

Here the code if anyone wants to tinker with it for fun:


Program ShowOres;
{$DEFINE SMART}
{$i srl/srl.simba}
{$i sps/sps.simba}
{$I SRL/SRL/misc/SmartGraphics.simba}
Const
COLORROCK = 5988191;
COLORORE = 2635354;
ROCKTOL = 15;
ORETOL = 10;
var
box1count,box2count,box3count,box4count,box5count,box6count:Integer;
box1countI,box2countI,box3countI,box4countI,box5countI,box6countI:Integer;
box1countR,box2CountR,box3CountR,box4CountR,box5CountR,box6CountR:String;
Procedure WriteRocks;
Begin
Writeln('|' + box1countR +'|' + box2countR + '|' + box3countR + '|');
Writeln('|' + box4countR +'|' + box5countR + '|' + box6countR + '|');
End;
Procedure GetPositions;
Begin
{
Box 1 Counts
}
Begin
if (box1count >= 65) and (box1countI >= 10) then //You need to wrap paranetheses around values that use <= ect.
//box1countI >= 10 then
Begin
box1countR := 'Iron'
End;
if (box1Count >= 65) and (box1countI <= 10) then
Begin
box1countR := 'Rock'
End;
if (box1Count <= 65) and (box1countI <= 10) Then

//then Greater than Less than must come first else it produces a Syntax error :P
Begin
box1countR := 'Nothing'
End;
End;
{
Box 2 Counts
}
Begin
if (box2count >= 65) and (box2countI >= 10) then

Begin
box2countR := 'Iron'
End;
if (box2Count >= 65) and (box2countI <= 10) then
Begin
box2countR := 'Rock'
End;
if (box2Count <= 65) and (box2countI <= 10) then

Begin
box2countR := 'Nothing'
End;
End;
{
Box 3 Counts
}
Begin
if (box3count >= 65) and (box3countI >= 10) then

Begin
box3countR := 'Iron'
End;
if (box3Count >= 65) and (box3countI <= 10) then
Begin
box3countR := 'Rock'
End;
if (box3Count <= 65) and (box3countI <= 10) then

Begin
box3countR := 'Nothing'
End;
End;
{
Box 4 Counts
}
Begin
if (box4count >= 65) and (box4countI >= 10) then

Begin
box4countR := 'Iron'
End;
if (box4Count >= 65) and (box4countI <= 10) then
Begin
box4countR := 'Rock'
End;
if (box4Count <= 65) and (box4countI <= 10) then

Begin
box4countR := 'Nothing'
End;
End;
{
Box 5 Counts
}
Begin
if (box5count >= 65) and (box5countI >= 10) then

Begin
box5countR := 'Iron'
End;
if (box5Count >= 65) and (box5countI <= 10) then
Begin
box5countR := 'Rock'
End;
if (box5Count <= 65) and (box5countI <= 10) then

Begin
box5countR := 'Nothing'
End;
End;
{
Box 6 Counts
}
Begin
if (box6count >= 65) and (box6countI >= 10) then

Begin
box6countR := 'Iron'
End;
if (box6Count >= 65) and (box6countI <= 10) then
Begin
box6countR := 'Rock'
End;
if (box6Count <= 65) and (box6countI <= 10) then

Begin
box6countR := 'Nothing'
End;
End;

End;
Procedure GetRocks;
Begin
box1count := CountColorTolerance(COLORROCK, 215, 182-50, 247, 213-50, ROCKTOL);
box2count := CountColorTolerance(COLORROCK, 247, 182-50, 279, 213-50, ROCKTOL);
box3count := CountColorTolerance(COLORROCK, 279, 182-50, 309, 213-50, ROCKTOL);
box4count := CountColorTolerance(COLORROCK, 215, 213-50, 247, 244-50, ROCKTOL);
box5count := CountColorTolerance(COLORROCK, 247, 213-50, 279, 244-50, ROCKTOL);
box6count := CountColorTolerance(COLORROCK, 279, 213-50, 309, 244-50, ROCKTOL);

box1countI := CountColorTolerance(COLORORE, 215, 182-50, 247, 213-50, ORETOL );
box2countI := CountColorTolerance(COLORORE, 247, 182-50, 279, 213-50, ORETOL );
box3countI := CountColorTolerance(COLORORE, 279, 182-50, 309, 213-50, ORETOL );
box4countI := CountColorTolerance(COLORORE, 215, 213-50, 247, 244-50, ORETOL );
box5countI := CountColorTolerance(COLORORE, 247, 213-50, 279, 244-50, ORETOL );
box6countI := CountColorTolerance(COLORORE, 279, 213-50, 309, 244-50, ORETOL );
ClearDebug;
Writeln('*******Rock results*******')
Writeln('BOX1:' + IntToStr(box1count) + '');
Writeln('BOX2:' + IntToStr(box2count) + '');
Writeln('BOX3:' + IntToStr(box3count) + '');
Writeln('BOX4:' + IntToStr(box4count) + '');
Writeln('BOX5:' + IntToStr(box5count) + '');
Writeln('BOX6:' + IntToStr(box6count) + '');
Writeln('*******Iron Results*******');
Writeln('BOX1:' + IntToStr(box1countI) + '');
Writeln('BOX2:' + IntToStr(box2countI) + '');
Writeln('BOX3:' + IntToStr(box3countI) + '');
Writeln('BOX4:' + IntToStr(box4countI) + '');
Writeln('BOX5:' + IntToStr(box5countI) + '');
Writeln('BOX6:' + IntToStr(box6countI) + '');
End;
Begin
SetupSRL;
ActivateClient;

box1countR := 'Nothing';
box2countR := 'Nothing';
box3countR := 'Nothing';
box4countR := 'Nothing';
box5countR := 'Nothing';
box6countR := 'Nothing';

GetRocks;
GetPositions;
WriteRocks;
End.

rj

2013-02-09 13:30:24

Got it. Didn't have smart enable messed up calculations