SRL Archive - OSR Help

Little more explanation on Tpoint, please.


Stevee

2010-03-15 12:57:07

Yes, I've read all the tutorials.

1. So a TPA (TpoinArray) is an array of x's and y's. Correct?
TPA[[COLOR=#000080]0[/COLOR]] := IntToPoint([COLOR=#000080]10[/COLOR], [COLOR=#000080]5[/COLOR]);
2. That's how a Tpoint is set. I can set TPA[1..XXX] like this too?
3. How many points are there in the standard TPA? Are they automatically created? Do I need SetArrayLength?
[code] [COLOR=#000000][B]For[/B][/COLOR] I := [COLOR=#000080]0[/COLOR] [COLOR=#000000][B]To[/B][/COLOR] High(TPA) [COLOR=#000000][B]Do[/B][/COLOR] [COLOR=#008000]// High = highest slot[/COLOR]
4.Is High(TPA) the highest declared numbered array? For instance, if I declared TPA[5], would the High(TPA) be 5?
5. In this small script from n3ss3s tutorial; [BANANA]

[COLOR=#000000][B]Procedure[/B][/COLOR] TPAMouseExample;
[COLOR=#000000][B]Var[/B][/COLOR]
TPA: TPointArray;
I, C: Integer;
[COLOR=#000000][B]Begin[/B][/COLOR]
SetArrayLength(TPA, [COLOR=#000080]10[/COLOR]);
[COLOR=#000000][B]For[/B][/COLOR] I := [COLOR=#000080]0[/COLOR] [COLOR=#000000][B]To[/B][/COLOR] High(TPA) [COLOR=#000000][B]Do[/B][/COLOR] [COLOR=#008000]// High = highest slot[/COLOR]
[COLOR=#000000][B]Begin[/B][/COLOR]
TPA[i].x := (i + [COLOR=#000080]1[/COLOR]) * [COLOR=#000080]10[/COLOR];
TPA[i].y := (i + [COLOR=#000080]1[/COLOR]) * [COLOR=#000080]20[/COLOR];
[COLOR=#000000][B]End;[/B][/COLOR]
[COLOR=#008000]// Now, we go through with it using mouse, watch...[/COLOR]
[COLOR=#000000][B]For[/B][/COLOR] C := [COLOR=#000080]0[/COLOR] [COLOR=#000000][B]To[/B][/COLOR] High(TPA) [COLOR=#000000][B]Do[/B][/COLOR]
[COLOR=#000000][B]Begin[/B][/COLOR]
MoveMouse(TPA[c].x, TPA[c].y);
Wait([COLOR=#000080]250[/COLOR]);
[COLOR=#000000][B]End;[/B][/COLOR]
[COLOR=#000000][B]End[/B][/COLOR];
[/BANANA] how come i is never declared?

Quickmarch

2010-03-15 13:00:34

1. Yes.
2. Yes.
3. It depends whether the array is dynamic or not.
4. The High() function is like Length(TPA) -1.
5. var I: Integer;..?

Naum

2010-03-15 13:01:44

1. Yes correct

2. You can set a TPoint like this TPA[0] := [Point(5, 10)]. Or like:
Var TP : TPoint;

Begin
TP := Point(6, 9);
TP.x := 6;
TP.y := 9;
End;
^ da same.

3. You have to set the length of the TPointArray, this is done by manually filling them in or by using a FindColors[].

4. You need to be more specific, but for what info you've given: yes.

5. All integers when declared for the first time in a script are 0. Furthermore, it is declared:

For I := 0

See ;).

Stevee

2010-03-15 16:07:31

Thanks for clearing up the integer issue. I get stumped over the littlest things, and I somehow missed that :=0, :p.

When I need x, y, do I need to call TPA[X].x, TPA[X].y, or can I simply call TPA[X]?

Markus

2010-03-15 16:21:23

tpa[index].x and tpa[index].y, where index is the point you want (for example 1 or 2 or w/ever).