SRL Archive - Help and Support

SafeColor in Int problems.


Dumpin

2007-12-16 11:06:17

program New;

{ GetMouseColor searches for the color the mouse is currently on.
also will safe those Color to an integer }
var
Color : Array[1..1] of integer;

Function GetMouseColor:boolean;
var
x, y, I, Color1: integer;
begin
GetMousePos(x,y);
begin
Color1 := Color1+ GetColor(x,y);
begin
For I := 0 to (GetArrayLength(Color)-1) do
Writeln('The Color is: '+inttostr(Color1)+ '. Color is safed to: '+inttostr(Color[I]));
Result := true;
end;
end;
end;


begin
GetMouseColor;
end.

Run it.. why do I get that error? :S

what i am trying is:

Get the color of where the mouse is Currently.
Then safes the Color To an integer.
the problem is I get this error.. please help me =D

mastaraymond

2007-12-16 11:16:18

What are you trying to do?

Color is a static array, you can't call it an array because its 1..1.. So it can only hold 1 value…

JuKKa

2007-12-16 11:32:32

that procedure doesent make sence :D

Edit:

Is it this what ur trying to do?

Program ColorSaver;

Var
Color: Array of Integer;
//NOT AArray [0..1] of integer because this value will change!

Function GetMouseColor: Boolean;
Var
X, Y: Integer;
Begin
GetMousePos(X, Y);
SetArrayLength( Color, GetArrayLength( Color ) + 1);
Color [ GetArrayLength ( Color ) -1 ] := GetColor(X, Y);
If( Color [ GetArrayLength ( Color ) -1 ] > 0)Then
Begin
Writeln('The Color Is: '+IntToStr(Color[ GetArrayLength (Color) -1 ])+'. Color is saved to Color['+IntToStr( GetArrayLength(Color)-1 )+']');
Result := True;
End;
End;

Begin
GetMouseColor
End.

Dumpin

2007-12-16 12:41:00

yep thats what i wanted to make ;D

n3ss3s

2007-12-16 13:28:58

Also, your array was from 1..1 and you attempted to go from 0 to 0 :)

I suggest using SetArrayLength, and then "0 to High(Array) Do"

R0b0t1

2007-12-16 15:44:47

What..?


function GetMouseColor: Integer;
var
xm, ym: Integer;
begin
GetMousePos(xm, ym);
Result:= GetColor(xm, ym);
end;

_

Miitchyy

2007-12-16 19:10:58

Yea, But he also wants to store it in an array

R0b0t1

2007-12-16 19:21:45

Still: What…?


var
ColorArray: TIntegerArray;

begin
SetArrayLength(ColorArray, Whatever);
ColorArray[0]:= GetMouseColor;
end.

Santa_Clause

2007-12-21 03:35:25

From: JuKKa
that procedure doesent make sence :D

Edit:

Is it this what ur trying to do?

Program ColorSaver;

Var
Color: Array of Integer;
//NOT AArray [0..1] of integer because this value will change!

Function GetMouseColor: Boolean;
Var
X, Y: Integer;
Begin
GetMousePos(X, Y);
SetArrayLength( Color, GetArrayLength( Color ) + 1);
Color [ GetArrayLength ( Color ) -1 ] := GetColor(X, Y);
If( Color [ GetArrayLength ( Color ) -1 ] > 0)Then
Begin
Writeln('The Color Is: '+IntToStr(Color[ GetArrayLength (Color) -1 ])+'. Color is saved to Color['+IntToStr( GetArrayLength(Color)-1 )+']');
Result := True;
End;
End;

Begin
GetMouseColor
End.


Nice standards :p

Wizzup?

2007-12-21 03:38:47

From: Santa_Clause
Nice standards :p


Yea! Capitalizing. :)

n3ss3s

2007-12-21 03:51:38

I also support capped. When you get used to them, small capped bold words look… small?