Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Delphi/Filling Arrays

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Tue Apr 17, 2007 4:19 pm    Post subject: Delphi/Filling Arrays Reply with quote

Hi, I'm looking for a way to fill delphi arrays (not constant variables so putting them on the const section and using "(1,2,3)" is out of the question) with variables. I can't see how I can use a loop for this because the variables I want to fill the array with don't have any particular order.

This is the current implementation (which is what I don't like, and I'm sure there is a better way, like there is in other languages, I just can't find it)

Code:

...
var
   intarray: array [0..3] of integer;
   var1, var2, var3, var4: integer;
...
begin
    intarray[0] := var1;
    intarray[1] := var2;
    intarray[2] := var3;
    intarray[3] := var4;
...
Back to top
View user's profile Send private message
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Tue Apr 17, 2007 4:30 pm    Post subject: Reply with quote

You can make a for statement? Idk what you're aiming for...But you could do something like..
Code:

...
var
   intarray: array [0..3] of integer;
   var1, var2, var3, var4,i: integer;
...
begin
for i:=0 to 3 do
intarray[i]:=var[i]
....

lol, i dont know what you want to do..but is that what you want to do?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25807
Location: The netherlands

PostPosted: Tue Apr 17, 2007 4:35 pm    Post subject: Reply with quote

I heard delphi 2005+ added something like defines that might be usable to fill it in...
But I don't really know a solution, except not defining variables that way, but define the variables inside the array
You might be able to make use of pointer arrays, but still requires code to target the variables

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping


Last edited by Dark Byte on Tue Apr 17, 2007 4:37 pm; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Tue Apr 17, 2007 4:35 pm    Post subject: Reply with quote

smartz993 wrote:
You can make a for statement? Idk what you're aiming for...But you could do something like..
lol, i dont know what you want to do..but is that what you want to do?


I stated in my post that your implementation of the for loop does not do what I want. Infact, that's not even valid code. var[i] is not an array.

Dark Byte wrote:
But I don't really know a solution, except not defining variables that way, but define the variables inside the array


delphi only lets me so this if they are constants

pointer arrays? ill look that up
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25807
Location: The netherlands

PostPosted: Tue Apr 17, 2007 5:02 pm    Post subject: Reply with quote

If you're talking about elements of the userinterface that you want to add to a array for easy usage then you might want to look at the ownerobject.controls array (and controlcount)
e.g formname.controls, panelx.controls, etc...

Because all objects on a control that can have objects inherit from tobject all objects have a tag property, and you can use that to seperate the objects you need from those you don't
lets say you have 10 buttons on the form, you all give them tag value 1234
Then you can fill a array of buttons with the following code:

Code:

var myarray[0..9] of Tbutton;
    i,j: integer;
begin
  j:=0;
  for i:=0 to formname.controlcount-1 do
    if formname.controls[i].tag=1234 then
    begin
      myarray[j]:=formname.controls[i];
      inc(j);
    end;

  for i:=0 to 9 do
  begin
    myarray[i].caption:='found';
    ....
  end;
end;


_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites