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]Some Questions
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Never Again
I post too much
Reputation: 0

Joined: 13 Jan 2007
Posts: 2000
Location: New Mexico

PostPosted: Sat Jan 05, 2008 6:22 pm    Post subject: [Delphi]Some Questions Reply with quote

I was recently making a Universal Flash Trainer for personal use when I was in need for some good ideas for functions. I came across Blader, but he uses VB6, so he couldn't help me. The functions I was in need for were Loading and saving text strings in a .txt and loading it from the path that the project is in.

Thanks
Back to top
View user's profile Send private message MSN Messenger
Blader
I post too much
Reputation: 2

Joined: 19 Jan 2007
Posts: 2049

PostPosted: Sat Jan 05, 2008 6:30 pm    Post subject: Reply with quote

The location for the project would be App.Path or Application.Path, something like that
_________________
Back to top
View user's profile Send private message
Never Again
I post too much
Reputation: 0

Joined: 13 Jan 2007
Posts: 2000
Location: New Mexico

PostPosted: Sat Jan 05, 2008 6:37 pm    Post subject: Reply with quote

It's Application.Path, but I'm talking about loading the .txt onto the form.
Back to top
View user's profile Send private message MSN Messenger
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Sat Jan 05, 2008 10:53 pm    Post subject: Reply with quote

Text onto a form? Like into an editbox?

Put this function anywhere, but make sure it's placed before the spot that you use it:
Code:

function LoadText(Path: string):string;
var
  TxtFile : TextFile;
  stringread : string;
begin
try
  AssignFile(TxtFile,Path) ;
  Reset(TxtFile) ;
  ReadLn(TxtFile, stringread) ;
  CloseFile(TxtFile);
  result:=stringread;
except
ShowMessage('Could not find proper .txt file');
end;


Then if you'd like to use this function to..perhaps load text from a txt file and put it into an edit box..you could do this:
Code:

Edit1.text:=LoadText('C:\WHATEVER.txt');


And if the txt file is in the same directory as the .exe, you can do this:
Code:

Edit1.text:=LoadText(ExtractFilePath(Application.exename)+'WHATEVER.txt');
Back to top
View user's profile Send private message
Never Again
I post too much
Reputation: 0

Joined: 13 Jan 2007
Posts: 2000
Location: New Mexico

PostPosted: Sat Jan 05, 2008 10:59 pm    Post subject: Reply with quote

Thank you. + Rep. How about saving the text into a .txt?
Back to top
View user's profile Send private message MSN Messenger
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Sat Jan 05, 2008 11:00 pm    Post subject: Reply with quote

You can do the opposite of the read. h/o.

Code:
function WriteText(WhatToWrite: string;Path:string):string;
var
  TxtFile : TextFile;
begin
try
  AssignFile(TxtFile,Path) ;
  Rewrite(TxtFile) ;
  WriteLn(TxtFile, WhatToWrite) ;
  CloseFile(TxtFile);
except
ShowMessage('Could not find proper .txt file');
end;


And to call this:
Code:
WriteText(edit1.text,'C:\WHATEVER.txt');
Back to top
View user's profile Send private message
Never Again
I post too much
Reputation: 0

Joined: 13 Jan 2007
Posts: 2000
Location: New Mexico

PostPosted: Sat Jan 05, 2008 11:18 pm    Post subject: Reply with quote

How can I define which text file I'm looking for. I've searched.
Back to top
View user's profile Send private message MSN Messenger
rapion124
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Mar 2007
Posts: 1095

PostPosted: Sun Jan 06, 2008 8:50 am    Post subject: Reply with quote

Have an edit box and the user can type in the name of the file into the edit box. Or you can just use an open dialog.
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: Sun Jan 06, 2008 10:17 am    Post subject: Reply with quote

The parameter in the functions called Path is where you put the path to the txt file. And yes, you could have an editbox that lets the user type in the path, and you can just use edit.text.
Back to top
View user's profile Send private message
Never Again
I post too much
Reputation: 0

Joined: 13 Jan 2007
Posts: 2000
Location: New Mexico

PostPosted: Sun Jan 06, 2008 10:37 am    Post subject: Reply with quote

So I'd use something like :
Code:
function LoadText(Path: string):string;
var
  TxtFile : TextFile;
  stringread : string;
begin
try
  AssignFile(TxtFile, Path.Application '\Resource\Text.txt') ;
  Reset(TxtFile) ;
  ReadLn(TxtFile, stringread) ;
  CloseFile(TxtFile);
  result:=stringread;
except
ShowMessage('Could not find proper .txt file');
end;

I'm confused with the "Stringread" part. What would I put there?
Back to top
View user's profile Send private message MSN Messenger
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Sun Jan 06, 2008 2:06 pm    Post subject: Reply with quote

To be honest, i'd like to help you but i'm not going to read your small fonts like this, hurts my eyes.

until you use regular fonts i'll help (I'm not threating or anything, i'm just saying that the font and color you're using are hurting my eyes, so i don't wanna acquire my eyes)
Back to top
View user's profile Send private message
Never Again
I post too much
Reputation: 0

Joined: 13 Jan 2007
Posts: 2000
Location: New Mexico

PostPosted: Sun Jan 06, 2008 3:10 pm    Post subject: Reply with quote

So I'd use something like
Code:
function LoadText(Path: string):string;
var
  TxtFile : TextFile;
  stringread : string;
begin
try
  AssignFile(TxtFile, Path.Application '\Resource\Text.txt') ;
  Reset(TxtFile) ;
  ReadLn(TxtFile, stringread) ;
  CloseFile(TxtFile);
  result:=stringread;
except
ShowMessage('Could not find proper .txt file');
end;

I'm confused with the "Stringread" part. What would I put there?
Back to top
View user's profile Send private message MSN Messenger
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Sun Jan 06, 2008 5:44 pm    Post subject: Reply with quote

Don't change my function at all. All you have to do is:
Code:

Edit1.Text:=LoadText(YOURPATHHERE);
Back to top
View user's profile Send private message
Never Again
I post too much
Reputation: 0

Joined: 13 Jan 2007
Posts: 2000
Location: New Mexico

PostPosted: Sun Jan 06, 2008 5:56 pm    Post subject: Reply with quote

smartz993 wrote:
Don't change my function at all. All you have to do is:
Code:

Edit1.Text:=LoadText(YOURPATHHERE);

What if other people had downloaded the project, and the .txt was in the folder. Wouldn't the path be different?
Back to top
View user's profile Send private message MSN Messenger
sponge
I'm a spammer
Reputation: 1

Joined: 07 Nov 2006
Posts: 6009

PostPosted: Sun Jan 06, 2008 6:09 pm    Post subject: Reply with quote

The way they find files is if there is not "header" for the file path, and it is like say /Resource/asdf.txt it will search for the resource folder in the same one your application was executed in and then look for asdf.txt.

it you just do /asdf.txt it will search the same folder for asdf.txt

Kaspersky wrote:
To be honest, i'd like to help you but i'm not going to read your small fonts like this, hurts my eyes.

until you use regular fonts i'll help (I'm not threating or anything, i'm just saying that the font and color you're using are hurting my eyes, so i don't wanna acquire my eyes)

Meaning you don't have eyes? That clears up a lot of stuff.

_________________
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
Goto page 1, 2  Next
Page 1 of 2

 
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