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] - [CPP] conversion

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

Joined: 08 Aug 2006
Posts: 929

PostPosted: Wed Nov 21, 2007 11:12 pm    Post subject: [Delphi] - [CPP] conversion Reply with quote

In c ++,

the code:

Code:
static const  blahhh;


Blahh is defined as a static const.
But, how would i convert that to delphi?

I already know, you reverse it as in:

Code:
Blahh : static const


but, static const isnt a type of var in delphi.
Back to top
View user's profile Send private message AIM Address MSN Messenger
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Wed Nov 21, 2007 11:54 pm    Post subject: Reply with quote

when I put

Code:

static const blahhh;


in a source file, the compiler warns me saying

Code:

error C4430: missing type specifier - int assumed. Note: C++ does not support default-int


That line doesn't make sense either, if it's a constant it should have some sort of value since you can't modify it later. If it does have a value and you've just omitted that for the post, when converted to delphi it should go under const, not var.

tl;dr integer

_________________
Back to top
View user's profile Send private message
slippppppppp
Grandmaster Cheater
Reputation: 0

Joined: 08 Aug 2006
Posts: 929

PostPosted: Thu Nov 22, 2007 1:09 am    Post subject: Reply with quote

It does have a value, it's value is loadlibrary, thats about it.
Back to top
View user's profile Send private message AIM Address MSN Messenger
Uzeil
Moderator
Reputation: 6

Joined: 21 Oct 2006
Posts: 2411

PostPosted: Thu Nov 22, 2007 3:34 am    Post subject: Reply with quote

No, static const blahhh; doesn't specify as to what blahhh is to contain, which can't happen with a constant, as you must initiate a value upon their declaration(Because they can't be modified later in code.).


Code:
const blah = 10;
Should be C++, I'm not actually sure if you need to declare variable types in C++ for constants or if the preprocessor/compiler gets it for you.

Code:
final int blahhh = 10;
Should be Java... just giving an example of another keyword here.

Code:
const blahhh = 10;
Delphi.
_________________


Mini Engine v3.0
Mipla v1.0

Reposted old threads out of the MS section.
Back to top
View user's profile Send private message
TheSorc3r3r
I post too much
Reputation: 0

Joined: 06 Sep 2006
Posts: 2404

PostPosted: Thu Nov 22, 2007 9:13 am    Post subject: Reply with quote

Uzeil, you do need to declare the type in C++:

Code:
static const int blehh= 0;


in delphi, you can make a whole list of constants if you want, using the keyword only once (this is from memory, I haven't used delphi in a while)..

Code:
const
 blehh = 10;
 blehh2 = 20;

_________________


Don't laugh, I'm still learning photoshop!
Back to top
View user's profile Send private message
HolyBlah
Master Cheater
Reputation: 2

Joined: 24 Aug 2007
Posts: 446

PostPosted: Thu Nov 22, 2007 10:20 am    Post subject: Reply with quote

here it is:
Code:
Const
[name]:[Type]=[value]
Ex:
Const
IAmAnInteger:integer=123;
IAmAString:String='Blah FTW~!';
Back to top
View user's profile Send private message
rapion124
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Mar 2007
Posts: 1095

PostPosted: Thu Nov 22, 2007 11:09 am    Post subject: Reply with quote

In delphi, you do not need to specify the type of data for a constant like you do for C++.

This is legal in Delphi:

Code:
const blahh = 5


This is also legal in C++:

Code:
static const blahh = 10


Because 10 to the compiler is an integer. Therefore, you can omit the type.
Back to top
View user's profile Send private message
slippppppppp
Grandmaster Cheater
Reputation: 0

Joined: 08 Aug 2006
Posts: 929

PostPosted: Thu Nov 22, 2007 1:40 pm    Post subject: Reply with quote

You guys dont get it, what im trying to convert is
C++

Code:
static const blahh = getmodulehandle(loadlibrary , ect.


And, convert it to delphi
Back to top
View user's profile Send private message AIM Address MSN Messenger
HolyBlah
Master Cheater
Reputation: 2

Joined: 24 Aug 2007
Posts: 446

PostPosted: Thu Nov 22, 2007 3:21 pm    Post subject: Reply with quote

slippppppppp wrote:
You guys dont get it, what im trying to convert is
C++

Code:
static const blahh = getmodulehandle(loadlibrary , ect.


And, convert it to delphi

const
blahh :Thandle=getmodulehandle(loadlibrary , ect.
Back to top
View user's profile Send private message
killersamurai
Expert Cheater
Reputation: 0

Joined: 10 Sep 2007
Posts: 197
Location: Colorado

PostPosted: Thu Nov 22, 2007 4:12 pm    Post subject: Reply with quote

You will not be able to use LoadLibrary with GetModuleHandle.
LoadLibrary returns HMODULE and GetModuleHandle takes in a LPCTSTR ( pointer to a constant string). Static doesn't exist in delphi as far as I know. Also, I always get an error when trying to assign a variable that is constant with a function that returns something in delphi. What I would do is
Code:

procedure TForm1.Button1Click(Sender: TObject);
var
something : HModule;

begin
something := GetModuleHandle('user32.dll');
...........
end;
end.
Back to top
View user's profile Send private message
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