View previous topic :: View next topic |
Author |
Message |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Wed Aug 22, 2007 1:26 pm Post subject: [Delphi]Making a notepad |
|
|
ok i only need to fix these ptoblems and im done...
open and save..
if openDialog.Execute then
RichEdit1.Text := openDialog.what.to.type.here.so.this.will.open.the.file?; use ReadFile? :O
and save
i save the file as a txt but i save nothing... it doesnt save anything becuase i didnt tell delphi what to save... how can i tell delphi to save RichEdit1.Text?
and how do i do Form1.Caption := save/openDialog.umm.what + ' - Notepad'?
sorry for all the questions thx
|
|
Back to top |
|
 |
XTrinityX Expert Cheater
Reputation: 0
Joined: 18 May 2006 Posts: 123 Location: Connecticut
|
Posted: Wed Aug 22, 2007 2:00 pm Post subject: |
|
|
First of all, delphi has a notepad component. Search for it on the internet. However, since your questions are kinda useful to answer, I will answer them.
I don't have delphi installed / opened but I believe the procedures LoadFromFile and SaveToFile exist. (or something of the sort).
So for open, it would be.
Code: | If OpenDialog.Execute then
begin
RichEdit.Lines.LoadFromFile(OpenDialog.FileName);
end;
|
For save...
Code: | If SaveDialog.Execute then
begin
RichEdit.Lines.SaveToFile(SaveDialog.FileName);
end;
|
For the form text, you need to extract the actual file name from the long file name. You will need to include StrUtils in your uses list to use this way. (Or you can come up with your own way to do so.)
Code: | var
TheFileName : string;
i : integer;
begin
TheFileName = OpenDialog.FileName;
i = TheFileName.Length - 1;
while i > 0
if (TheFileName[i] = "/") or (TheFileName[i] = "\") then
begin
Form1.Text = (MidStr(TheFileName,(i+2)) + " - Notepad");
i = 1;
end;
i = i - 1;
end;
|
Again, I don't have delphi open, so these may not be exactly right.
|
|
Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Wed Aug 22, 2007 2:06 pm Post subject: |
|
|
thx gonna try it =)
edit: yea it works! =)
this notepad sux... its like buggy and ugly :O
u said there's a notepad component? ill google it see what i can find...
umm 1 more question if u dont mind to answer :O
the keys all messed up, end changed the lagnuage, home acts like end, single click highlights text... =\ can be fixed? :]
umm the 3rd code, the title... i fixed everything and now i have nothing to fix and it doesnt work it says missing operator at "if" below while i > 0
|
|
Back to top |
|
 |
MadDoom Cheater
Reputation: 0
Joined: 27 Dec 2006 Posts: 38
|
Posted: Thu Aug 23, 2007 1:40 am Post subject: |
|
|
XTrinityX wrote: |
Code: | var
TheFileName : string;
i : integer;
begin
TheFileName = OpenDialog.FileName;
i = TheFileName.Length - 1;
while i > 0
if (TheFileName[i] = "/") or (TheFileName[i] = "\") then
begin
Form1.Text = (MidStr(TheFileName,(i+2)) + " - Notepad");
i = 1;
end;
i = i - 1;
end;
|
|
this is realy long way to do that.
here is a better way: Code: |
form1.caption:=ExtractFileName(opendialog.FileName) |
|
|
Back to top |
|
 |
|