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 


Problem with Delphi integers

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Look-Familiar
Newbie cheater
Reputation: 0

Joined: 03 Jun 2008
Posts: 19
Location: US

PostPosted: Tue Jul 21, 2009 7:58 pm    Post subject: Problem with Delphi integers Reply with quote

So this is my Source Code:

Code:

procedure TForm1.Edit1Change(Sender: TObject);
var
yourName, ID: HWND;
yay: String;
i: Integer;
begin
if Edit1.Text <> '' then
  begin
  yay := IntToStr(StrToInt(Edit1.Text) * 8);
  yourName := FindWindow('TMainForm', 'Cheat Engine 5.5');
  if yourName <> 0 then
    begin
    ID := FindWindowEx(yourName, 0, 'TPanel', nil);;
    yourName := FindWindowEx(ID, 0, 'TEdit', nil);
    SendMessage(yourName, EM_SETSEL, 0, -1);
    for i := 1 to Length(yay) do
      begin
      SendMessage(yourName, WM_CHAR, Word(yay[i]), 0);
      end;
    end;
  end
else if Edit1.Text = '' then
  begin
  yay := '';
  yourName := FindWindow('TMainForm', 'Cheat Engine 5.5');
  if yourName <> 0 then
    begin
    ID := FindWindowEx(yourName, 0, 'TPanel', nil);;
    yourName := FindWindowEx(ID, 0, 'TEdit', nil);
    SendMessage(yourName, EM_SETSEL, 0, -1);
    SendMessage(yourName, WM_CHAR, VK_BACK, 0);
    end;
  end
end;


The desired effect is to take whatever I type into that EditBox and multiply it by 8 and put it into Cheat Engine's search box.

Now it works all until I make it to the 11th character and then it says:

"NumberYouTypedIn" is not a valid integer value.

I am not a beginner with Delphi Programming but I am not an expert either. Is there something I can be doing that will not cause the error mentioned?

I'm using CodeGear Delphi 2009. The program only has that one EditBox.

Note: My variables are just temp until I finish the program. That's just how I do.

_________________
Good times =D
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Dark Byte
Site Admin
Reputation: 475

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

PostPosted: Tue Jul 21, 2009 8:51 pm    Post subject: Reply with quote

you do know you can use the custom scantype to do that for you right ? (shl scanvalue with 3)

anyhow, use a try/except around it, or use trystrtoint, or use val

a 11th character integer is too big

_________________
Tools give you results. Knowledge gives you control.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Look-Familiar
Newbie cheater
Reputation: 0

Joined: 03 Jun 2008
Posts: 19
Location: US

PostPosted: Tue Jul 21, 2009 10:59 pm    Post subject: Reply with quote

I didn't know that I could do that or that the custom scantype even existed so thank you for the suggestion. I don't know what you mean by shl by three but I might figure it out on my own.

As for the program solution I opted to go with a two pronged fix since I can't have an integer that large; I made the EditBox's MaxLength 9 and I put a try/except around the code to catch the exceptions.

Thank you for the info Dark Byte

_________________
Good times =D
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Dark Byte
Site Admin
Reputation: 475

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

PostPosted: Wed Jul 22, 2009 5:05 pm    Post subject: Reply with quote

I've just posted a custom scan script that does this in the flash section: http://forum.cheatengine.org/viewtopic.php?t=439459
_________________
Tools give you results. Knowledge gives you control.

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