Link to home
Start Free TrialLog in
Avatar of joelsilva
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...
ASKER CERTIFIED SOLUTION
Avatar of LMuadDIb
LMuadDIb
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of joelsilva
joelsilva

ASKER

Hi friend... I deeply appreciate your suggestion.

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!!!
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(extractfilepath(application.exename)+'birthdays.ini');
with inifile do
begin
     birthdate:=readstring('Birthdays',datetimetostr(date),'FALSE');
     if birthday <> 'FALSE' then
        memo1.lines.add(birthdate + '  ' + readstring('Birthdays',datetimetostr(date)+'Name',''))
free
end;
end;

3/ On entering birthdays:

procedure tform1.writebirthday(Name:string; Birth:string);

var inifile:tininfile;
birthdate:string;
begin
 inifile:=tinifile.create(extractfilepath(application.exename)+'birthdays.ini');
with inifile do
begin
     writestring('Birthdays',birth,birth);
    writestring('Birthdays',birth + 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
 
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',datetimetostr(date)+'Name',''))

... will show a result like:

19/09/2004 Michael

Regards,

Hypoviax
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',datetimetostr(date)+'Name',''))
==========================================================
ERROR MESSAGE: Undeclared Identifier: 'readstring'

Could you help me with these?

Thanks very much for your precious comments.
Is it possible that my BIRTHDAYS.INI file only shows me:
=============================
[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.
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.
Thanks very much guys...

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
Can you answer? :)
sure...

writestring('Birthdays','Joel',datehere);

readstring('Birthdays','Joel','');

I might write in delphi and repost if this doesnt help you out

Regards,

Hypoviax
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
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
HSC? What does it mean?

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
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','enter a name','');
 inifile:=tinifile.create(extractfilepath(application.exename)+'birthdays.ini');
with inifile do
begin
     writestring('Birthdays',birthdate,birthdate);
    writestring('Birthdays',birthdate + 'name',name);
free
end;
end;


procedure TForm1.FormCreate(Sender: TObject);
var inifile:tinifile;
birthdate:string;
begin
 inifile:=tinifile.create(extractfilepath(application.exename)+'birthdays.ini');
with inifile do
begin
     birthdate:=readstring('Birthdays',datetimetostr(date),'FALSE'); //determine if there is a birthday today
     if birthdate <> 'FALSE' then
        memo1.lines.add(birthdate + '  ' + readstring('Birthdays',datetimetostr(date)+'name','')); //read any birthdays today
free
end;
end;

Regards,

Hypoviax
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).
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!