adding "Tip for the day" or "Thought for the day" to your application

I can't seem to come up with too much on google, and there's absolutely nothing on EE, so it's time to add this one to the index of knowledge...

I want to have a "tip for the day" every time the application loads.
Typically the form has a scroller so you can see "tomorrow's" tip or "yesterdays tip" too.
There's usually a checkbox that says "Always show tips when the application starts".

I suppose the hints themselves would be stored in a txt file.

Can any expert mash together some kind of randomise function to fetch a random tip and place it in a memo, or even better, point me to an existing example or component for this.

LVL 13
Who is Participating?
bogdan_iulyConnect With a Mentor Commented:

I see you have found a method to do it, but I thought this ideea might help you more.

You can use the following method to display the tip of the day:

The StringList is a little buggy, because if you have a tip on two lines, it will separate it and it will show it as two different tips.
Store the tips in Tips.ini, for example, in a structure like the one below:



1. Check if ini exists and if so, execute steps 2-5, otherwise show a message, hide the panel that displays the tip, etc ... This depends on your implementation.
2. Read from the ini the ID of the last shown tip (=LastID) and the number of tips (=NrTips); both with a default value of 0
3. Increment LastID
4. If LastID is bigger than NrTips, then make the LastID equal to the ID of the first tip.
5. Save LastID to the ini file.

If you need code, just let me know and I'll create the program and post the code here.
MerijnBConnect With a Mentor Sr. Software EngineerCommented:
check here, lots of them:
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

BedouinDNConnect With a Mentor Commented:
The Jedi VCL also has a Tip of the Day component.
rfwoolfAuthor Commented:
Hmm... thanks...
but it seems they all like to use dialogs! I want the tip of the day to appear in my login form.
I've opened up JvTipOfDay.pas but it doesn't seem to have an associated dfm - i.e. its form may be created at runtime.
I might have to create this myself :(
MerijnBSr. Software EngineerCommented:
ok, what part are you looking for then? You say that you want to make it in your login form yourself.
rfwoolfAuthor Commented:
Hmmm... it should be quite easy to do. I would have a text file with all the tips.
Then I would have an INI file which lists the last line number (tip number) that was loaded.
The application would check the line number, incremement it by 1, then load the number into the editbox.

I suppose it would be nice if it **looked** like the Jedi VCL component does, you know, that "typical" tip for the day look.

Should be easy enough :)
If I have any trouble I will post a new question asking help for that so we don't contaminate the points for this question
MerijnBSr. Software EngineerCommented:
so... what is it you need for this question then?
rfwoolfAuthor Commented:
MerjinB I am keeping this question open a bit longer to see if there are any other answers.
MerijnBSr. Software EngineerCommented:
ok, got it
rfwoolfAuthor Commented:
I ended up using a stringlist's LoadFromFile, and then saying MyStringList.string[4] if I want the 4th tip, etc.
To record the number of the latest tip, i store in an INI file (although technically it can be stored in the txt file)

I will close this question soon.
Thanks for all the answers
Did any of this help you?

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.