?
Solved

How to setup a user manipulated edit field?

Posted on 2003-03-29
4
Medium Priority
?
141 Views
Last Modified: 2010-04-04
Hello,

I have a cool database program written in Delphi2 that allows a user to enter a bunch of data then get averages and stuff back. But I would like for the user to be able to type their name in a field next to the database somewhere in order to personalize it.
If I use a standard edit field it loses the data each time the program is closed then opens blank. How can I put a field in my program that accepts the users' name and saves it?

Thanks in advance!
0
Comment
Question by:lontek
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 1

Expert Comment

by:grolschisgood
ID: 8233252
you have several options available

1.  write the name into the windows registry
2. save it into a text file in your program directory
3. save it into the same database as the other data.  either into a different table or against each record of data that the user enters.

whats your pref i give you a hand



0
 
LVL 1

Author Comment

by:lontek
ID: 8242226
Hi,
Number 2 looks like a nice way to do it. Please inform and
I will plan to give it a try!

Thanks.
0
 
LVL 1

Expert Comment

by:grolschisgood
ID: 8245008
as a quick way to provide simple setup information to a application i sometimes use a text file (with same name as executable eg myprog.exe and myprog.txt) with information it it like

NAME=<data>
DESCRIPTION=<data>

where name and description act like fields in a database.  This method is setting up name value pairs.

you need the following global variables setup

FSetupInfo : Tstrings;
SetupFileName : string;

then use the following code to read the txt file of the same name as my application into my Tstring list

  FSetupInfo:=TStringList.Create;
  SetupFileName:=ChangeFileExt(Application.ExeName, '.TXT')
  if FileExists(SetupFileName) then
    FSetupInfo.LoadFromFile(SetupFileName);
  else WriteLast('Configuration file is missing.');

once loaded you can refer to the values of any of the "fields" using the following...

Edit1.text:=FSetupInfo.Values['DESCRIPTION'];

change a value of one of the "fields" with ...

FSetupInfo.Values['DESCRIPTION']:=Edit2.text;

and then save the changes back to the config file with

FSetupInfo.SavetoFile(SetupFileName);

this is basically a INI file but without groups.  Search for INI Files in delphi help for an easy example of using INI files.

each user with the applicaiton installed on their computer can save their personal details into this file

hope this helps


0
 
LVL 1

Accepted Solution

by:
grolschisgood earned 150 total points
ID: 8245009
as a quick way to provide simple setup information to a application i sometimes use a text file (with same name as executable eg myprog.exe and myprog.txt) with information it it like

NAME=<data>
DESCRIPTION=<data>

where name and description act like fields in a database.  This method is setting up name value pairs.

you need the following global variables setup

FSetupInfo : Tstrings;
SetupFileName : string;

then use the following code to read the txt file of the same name as my application into my Tstring list

  FSetupInfo:=TStringList.Create;
  SetupFileName:=ChangeFileExt(Application.ExeName, '.TXT')
  if FileExists(SetupFileName) then
    FSetupInfo.LoadFromFile(SetupFileName);
  else WriteLast('Configuration file is missing.');

once loaded you can refer to the values of any of the "fields" using the following...

Edit1.text:=FSetupInfo.Values['DESCRIPTION'];

change a value of one of the "fields" with ...

FSetupInfo.Values['DESCRIPTION']:=Edit2.text;

and then save the changes back to the config file with

FSetupInfo.SavetoFile(SetupFileName);

this is basically a INI file but without groups.  Search for INI Files in delphi help for an easy example of using INI files.

each user with the applicaiton installed on their computer can save their personal details into this file

hope this helps


0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month8 days, 20 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question