joelsilva
asked on
Is it possible to do this WITHOUT a database?
Hi folks,
I´d like to develop a very SIMPLE application which i could add some people birthday´s day and, when a day is the birthday of someone, the application alerst me. I didn´t like to use any database (even MS Access). Is it possible to implement what i want WITHOUT any database? Do you have any idea/suggestion?
Best regards...
I´d like to develop a very SIMPLE application which i could add some people birthday´s day and, when a day is the birthday of someone, the application alerst me. I didn´t like to use any database (even MS Access). Is it possible to implement what i want WITHOUT any database? Do you have any idea/suggestion?
Best regards...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I dont know if you help me on my second question or not, but what do you think about using a MEMO OR LISTVIW in order to use a TREEVIW? I dont imagine how could a TREEVIEW structure be like this: the user NAME and his BIRTHDAY.
I would use inifiles:
Steps:
1/ Declare inifiles in uses
2/Form load:
var inifile:tininfile;
birthdate:string;
begin
inifile:=tinifile.create(e xtractfile path(appli cation.exe name)+'bir thdays.ini ');
with inifile do
begin
birthdate:=readstring('Bir thdays',da tetimetost r(date),'F ALSE');
if birthday <> 'FALSE' then
memo1.lines.add(birthdate + ' ' + readstring('Birthdays',dat etimetostr (date)+'Na me',''))
free
end;
end;
3/ On entering birthdays:
procedure tform1.writebirthday(Name: string; Birth:string);
var inifile:tininfile;
birthdate:string;
begin
inifile:=tinifile.create(e xtractfile path(appli cation.exe name)+'bir thdays.ini ');
with inifile do
begin
writestring('Birthdays',bi rth,birth) ;
writestring('Birthdays',bi rth + name,name);
free
end;
end;
Hope this helps. I did off top of my head so there may be a couple of errors.
Regards,
Hypoviax
Steps:
1/ Declare inifiles in uses
2/Form load:
var inifile:tininfile;
birthdate:string;
begin
inifile:=tinifile.create(e
with inifile do
begin
birthdate:=readstring('Bir
if birthday <> 'FALSE' then
memo1.lines.add(birthdate + ' ' + readstring('Birthdays',dat
free
end;
end;
3/ On entering birthdays:
procedure tform1.writebirthday(Name:
var inifile:tininfile;
birthdate:string;
begin
inifile:=tinifile.create(e
with inifile do
begin
writestring('Birthdays',bi
writestring('Birthdays',bi
free
end;
end;
Hope this helps. I did off top of my head so there may be a couple of errors.
Regards,
Hypoviax
You could do searches easily my using a simple for loop
Also using inifiles if you want to find if there is anyones birthday on anyother day other than today just write a query similar to step2 but with the specified date instead of the current day's date.
By the way this line of code from my example....
memo1.lines.add(birthdate + ' ' + readstring('Birthdays',dat etimetostr (date)+'Na me',''))
... will show a result like:
19/09/2004 Michael
Regards,
Hypoviax
By the way this line of code from my example....
memo1.lines.add(birthdate + ' ' + readstring('Birthdays',dat
... will show a result like:
19/09/2004 Michael
Regards,
Hypoviax
ASKER
Hi,
I am very glad Hypoviax, because you also create something similar to LMUAD but using other way. I love your recommendation.
Just 2 points:
1) Why my BIRTHDAYS.INI file shows me:
[Birthdays]
01/01/1978=01/01/1978
01/01/1978joel=joel
2) There a error in this line:
========================== ========== ========== ========== ==
memo1.lines.add(birthday + ' ' + readstring('Birthdays',dat etimetostr (date)+'Na me',''))
========================== ========== ========== ========== ==
ERROR MESSAGE: Undeclared Identifier: 'readstring'
Could you help me with these?
Thanks very much for your precious comments.
I am very glad Hypoviax, because you also create something similar to LMUAD but using other way. I love your recommendation.
Just 2 points:
1) Why my BIRTHDAYS.INI file shows me:
[Birthdays]
01/01/1978=01/01/1978
01/01/1978joel=joel
2) There a error in this line:
==========================
memo1.lines.add(birthday + ' ' + readstring('Birthdays',dat
==========================
ERROR MESSAGE: Undeclared Identifier: 'readstring'
Could you help me with these?
Thanks very much for your precious comments.
ASKER
Is it possible that my BIRTHDAYS.INI file only shows me:
========================== ===
[Birthdays]
joel=01/01/1978
========================== ===
???
==========================
[Birthdays]
joel=01/01/1978
==========================
???
"The point is: i dont imagine how to put the NAMES and DATES in this tv.dat file... Is there any way to put this by putting the information in a Edit1 and Edit2 and click on INSERT?"
You can add 2 edits (1 called "editName" and another called "editBirthday") to the form and another button that will insert the edits texts into the treeview
add this code to the Insert event:
procedure TForm1.InsertClick(Sender: TObject);
var
xItem: TTreeNode;
begin
with treeview1 do begin
xItem:= Items.Add ( Nil, editName.text) ;
Items.AddChild ( xItem, editBirthday.Text );
end;
end;
"Do you a have a clue how could i implement a search? I am sorry, but i never used this kind of way that you recommend me."
Add Another button called Search and use this code:
// Example: Search for Birthday in TreeView1 and select item
procedure TForm1.Button1Click(Sender : TObject);
var
Node: TTreeNode;
begin
//either
Node := TreeItemSuchen(TreeView1, 'Birthday');
TreeView1.Selected := Node;
//or
TreeView1.Selected := TreeItemSuchen(TreeView1, '2/2/79');
end;
// Search a TreeItem through its Text property
// Return value is a TreeNodeObject
function Form1.TreeItemSearch(TV: TTreeView; sBirthday: string): TTreeNode;
var
i: Integer;
iItem: string;
begin
if (TV = nil) or (sBirthday = '') then Exit;
for i := 0 to TV.Items.Count - 1 do
begin
iItem := TV.Items[i].Text;
if sBirthday = iItem then
begin
Result := TV.Items[i];
Exit;
end
else
begin
Result := nil;
end;
end;
end;
Now you have to be careful with your birthday DATe format so you can search for it correctly.
Instead of a string for DATE you should use a TDateTime and a TDateTimePicker component to help select the dates.
You can add 2 edits (1 called "editName" and another called "editBirthday") to the form and another button that will insert the edits texts into the treeview
add this code to the Insert event:
procedure TForm1.InsertClick(Sender:
var
xItem: TTreeNode;
begin
with treeview1 do begin
xItem:= Items.Add ( Nil, editName.text) ;
Items.AddChild ( xItem, editBirthday.Text );
end;
end;
"Do you a have a clue how could i implement a search? I am sorry, but i never used this kind of way that you recommend me."
Add Another button called Search and use this code:
// Example: Search for Birthday in TreeView1 and select item
procedure TForm1.Button1Click(Sender
var
Node: TTreeNode;
begin
//either
Node := TreeItemSuchen(TreeView1, 'Birthday');
TreeView1.Selected := Node;
//or
TreeView1.Selected := TreeItemSuchen(TreeView1, '2/2/79');
end;
// Search a TreeItem through its Text property
// Return value is a TreeNodeObject
function Form1.TreeItemSearch(TV: TTreeView; sBirthday: string): TTreeNode;
var
i: Integer;
iItem: string;
begin
if (TV = nil) or (sBirthday = '') then Exit;
for i := 0 to TV.Items.Count - 1 do
begin
iItem := TV.Items[i].Text;
if sBirthday = iItem then
begin
Result := TV.Items[i];
Exit;
end
else
begin
Result := nil;
end;
end;
end;
Now you have to be careful with your birthday DATe format so you can search for it correctly.
Instead of a string for DATE you should use a TDateTime and a TDateTimePicker component to help select the dates.
then everytime you start your app or destroy it you can load/save the treeview object with ReadComponent & WriteComponent
and search the treeview upon startup, and once a day
basically the same as with the memo, except instead of the info being in text, it will be in binary.
and search the treeview upon startup, and once a day
basically the same as with the memo, except instead of the info being in text, it will be in binary.
ASKER
Thanks very much guys...
LMuadDIb: best regards for you. Deeply thank you for providing me special attention.
LMuadDIb: best regards for you. Deeply thank you for providing me special attention.
Sorry, i would have responded but i think i am operating at a differnet time zone!
Regards,
Hypoviax
Regards,
Hypoviax
ASKER
Can you answer? :)
sure...
writestring('Birthdays','J oel',dateh ere);
readstring('Birthdays','Jo el','');
I might write in delphi and repost if this doesnt help you out
Regards,
Hypoviax
writestring('Birthdays','J
readstring('Birthdays','Jo
I might write in delphi and repost if this doesnt help you out
Regards,
Hypoviax
ASKER
OH man... Thankx very much. Could you rewrite in delphi, because i don´t know what question did you answer me (the first or the second) :)
yeah i did in delphi but i did off top of me head
Im doing my HSC so give me a couple of days
Im doing my HSC so give me a couple of days
Simply,
1/Alerts can be done by say showmessage('Its ' + name + 'birthday today');
2/ My method is using inifiles - no databases at all - better yet they are easy to transport
1/Alerts can be done by say showmessage('Its ' + name + 'birthday today');
2/ My method is using inifiles - no databases at all - better yet they are easy to transport
ASKER
HSC? What does it mean?
No problem friend... When you have time, if you could, do that (don´t matter).
I deeply thank you.
No problem friend... When you have time, if you could, do that (don´t matter).
I deeply thank you.
haha,
Obviously u dont come from Australia. HSC stands for Higher School Certificate.
Yeah, ill post it up soon, the HSC exams are in about 27 days
Regards,
Hypoviax
Obviously u dont come from Australia. HSC stands for Higher School Certificate.
Yeah, ill post it up soon, the HSC exams are in about 27 days
Regards,
Hypoviax
Here's the code. Any birthdays on the day will be displayed in the memo control. You can change this around depending on how you want it:
procedure TForm1.Button1Click(Sender : TObject); //This is for adding dates
var inifile:tinifile;
birthdate:string;
begin
birthdate:=inputbox('date' ,'enter a date','');
name:=inputbox('name','ent er a name','');
inifile:=tinifile.create(e xtractfile path(appli cation.exe name)+'bir thdays.ini ');
with inifile do
begin
writestring('Birthdays',bi rthdate,bi rthdate);
writestring('Birthdays',bi rthdate + 'name',name);
free
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var inifile:tinifile;
birthdate:string;
begin
inifile:=tinifile.create(e xtractfile path(appli cation.exe name)+'bir thdays.ini ');
with inifile do
begin
birthdate:=readstring('Bir thdays',da tetimetost r(date),'F ALSE'); //determine if there is a birthday today
if birthdate <> 'FALSE' then
memo1.lines.add(birthdate + ' ' + readstring('Birthdays',dat etimetostr (date)+'na me','')); //read any birthdays today
free
end;
end;
Regards,
Hypoviax
procedure TForm1.Button1Click(Sender
var inifile:tinifile;
birthdate:string;
begin
birthdate:=inputbox('date'
name:=inputbox('name','ent
inifile:=tinifile.create(e
with inifile do
begin
writestring('Birthdays',bi
writestring('Birthdays',bi
free
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var inifile:tinifile;
birthdate:string;
begin
inifile:=tinifile.create(e
with inifile do
begin
birthdate:=readstring('Bir
if birthdate <> 'FALSE' then
memo1.lines.add(birthdate + ' ' + readstring('Birthdays',dat
free
end;
end;
Regards,
Hypoviax
ASKER
Hey HYPO, i dont have Delphi now but i will test your code at night.
Again friend, i thank you very much for your attention and for providing help.
Best regards...
I will add you in my friend list (i´ll show you where it is).
Again friend, i thank you very much for your attention and for providing help.
Best regards...
I will add you in my friend list (i´ll show you where it is).
Cool, no worries, any time
If u test it put the days date in and, restart the app, otherwise youll have to wait until the actual date
This morning for you? Because it is for me! And it is the 23rd!
ASKER
The point is: i dont imagine how to put the NAMES and DATES in this tv.dat file... Is there any way to put this by putting the information in a Edit1 and Edit2 and click on INSERT?
Do you a have a clue how could i implement a search? I am sorry, but i never used this kind of way that you recommend me.
Thanks very much!!!