Link to home
Start Free TrialLog in
Avatar of jjhj
jjhj

asked on

Label changing part 3

Will you give me an example, on displaying a new and different text on a  label every 24 hrs for a period of approximately six months, with the aid of a TTimer.

Here is a sample of what i have, however,  if i add a second message for a new 24 hr period , it comes up immediatly after the first message even though i add a new time interval.

unit Unit1;

interface

uses
 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls;

type
   TForm1 = class(TForm)
    Timer1: TTimer;
     btStart: TButton;
     Label1: TLabel
     procedure Timer1Timer(Sender: TObject);
     procedure btStartClick(Sender: TObject);
private
      {Private declaration}
public
       {Public declaration}
end;

var
  Form1: TForm1;
  PassedTime: Cardinal;
implementation

{$R*.DFM]

procedure TForm1.Timer1Timer(Sender: TObect);
begin
inc(PassedTime);
if PassedTime=1440 then;
   begin
   MessageDlg('24 hours passed',mtInformation,[mbok],0);
   label1.caption:='message 1';
 (i tried adding second message here for a new 24hr period)
    PassedTIme:=0;
end;

procedure TForm1.btStartClick(Sender: TObject);
begin
timer1.interval:=60000;

end;

end.

signed,
jjhj
ASKER CERTIFIED SOLUTION
Avatar of Greedy
Greedy

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 jjhj
jjhj

ASKER

Dearest of Greeds:

Before i let your answer fly,  I thought it was well done,
i noticed that your solution must use a showmessage in order to anvance the message to the next. Is this neccessary??
also,  does the message box must say "project 1" or is that a new question.

i used in the program'
timer1.enabled:=false;
label1.caption:='new message';
showmessage('new message');
timer1.enabled:=true;

(repeat above with second message)

it worked but can we  avoid the showmessage

you're doing great

jjhj
yeah...that show message was just for the example...why didn't you just try it and see that would have been faster than typeing in this question...(if you set the timer interval to something less than 24 hours)...
>>>> does the message box must say "project 1" or is that a new question.
what do you mean by this...are you talking about the caption of the form...if you are you can set the caption proporty by useing the object inspector or by doing this in the OnCreate of your form (Form1)

Form1.Caption := 'Whatever you want';

Now you might be talking about the fact that Delphi thinks your executable is called project1 in that case you must change the name of your project...the easiest way to do this is to go to File then Save Project As and then save the project as whatever maby TimerThingy...

Oh well that should do it.


Avatar of jjhj

ASKER

greedy,

one last problem
when i add new messages for a new 24 hr period,  the second and third message come up rapidly.

in otherwords,  the first message comes up in 24hr
but the following message that i want to come up, automatically,
for the following 24 hr periods, comes up immediately after the first message

sorry
jjhj.


what the hell are you doing...
so like every day needs a diferent thing to happen?
screw it do this
make a global var called TimeNum

In the OnCreate of the form do this
TimeNum := 0;

In the OnTimer event of the timer do this
inc(TimeNum)
MyTimerCall

make a procedure called MyTimerCall and do this
Case TimeNum of
  1 : {Code for first day}
  2 : {Code for second day}
  3 : {Code for third day}
  4 : {...}
  5 :
  6 :
  7 : {set TimeNum Back to 0 for weekly processing}
end;

that way you can do different things for each day of the week
if you want to be more specific on the day of the week use the
DayOfWeek function
The DayOfWeek function returns the day of the week of the specified date as an integer between 1 and 7. Sunday is the first day of the week and Saturday is the seventh.

That way in the MyTimerCall procedure you can do a
case DayOfWeek(Now) of
  1 : {Sunday}
  2 : {Monday}
  3 : {Teusday}
  4 : {...}
  5 : {...}
  6 : {...}
  7 : {Saturday}
end;

if that does't work I sugest that you paste your crappy code here so I can edit it for you
if you need even better automated process control than this I sugest you purchase Opalis Robot from www.opalis.com

of coarse with a bit of understanding you could write one!

Avatar of jjhj

ASKER

Greedy;

testy testy testy.
take it easy baby...

now what i have so far,  that is close is..

procedure TForm1.FormCreate(Sender: Tobject);
begin
Timer1.Enabled:=True;
end;

procedure TForm1.updatelabel (Sender: Tobject);
begin
Timer1.Enabled:=False;
Label1.Caption:='new message1';
Timer1.enabled:=True;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled:=False;
Label1.Caption:='new message2';
ShowMessge('new message2');
Timer1.Enabled:=True;

Timer1.Enabled:=False;
Label1.Caption:='new message3';
ShowMessage('new message3');
Timer1Enabled:=True;

{ect. ect. to maybe 30}

end;

NOW GREEDY
SELF CONTROL
mellow,
think  serene

jjhj

well this code is like "not good"

procedure TForm1.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled:=False;
Label1.Caption:='new message2';
ShowMessge('new message2');
Timer1.Enabled:=True;

Timer1.Enabled:=False;
Label1.Caption:='new message3';
ShowMessage('new message3');
Timer1Enabled:=True;

{ect. ect. to maybe 30}

end;

as you know what this code does it wait the given first interval and then does all the events that you have listed in that code block this is because the OnTimer event is trigered evertime the interval piriod is set...that means all the code in the OnTimer event is executed.  if you only want one message to occure in the OnTimer event you have to tell it what to do for this instance of being called.  Look above and you will see that case statment thing.  You haven't really told me what this program is going to do, hopefully what ever the daily process is it can be automated so that one block of code can adapt itself to all days that way you don't have to write code blocks for each and ever day that goes by.  just tell me what this program is going to be used for and I'll come up with something that will work better than that slag code that you have writen above...damn...that was way wied sudden fealing of deja veu that I have done this before in this very chair facing this very same way and that I even type this...this meaning that I rember typing this deja vue thing into a window like this...from what this deja vue thing that I rember I get kicked off this system...I don't really know why...yet...hummm....oh well, anyway that code snippet that I typed in above (in the other message) should be analyised more closely...because if you understood it you will probably be able to figure out what it is you want...but if you can't just type in another message...I wasn't able to get to the internet over the weekend and stuff so this response might come to you a bit late...
Avatar of jjhj

ASKER

greedy;

you were actually too serene on your last response and that worries me.   but that is a different issue.

what i actually want
now don't brain freeze on me is........

about 60 label captions that come up every 24 hrs

should i just use 60 timers??
or is that lame

i know what you are thinking
this whole thing is lame

but this is IMPORTANT ok
so you be chillin

thanks
jjhj

ps.  remember what clint said
excess in control  
So these Captions are always different...like there is no way they can be dirived from the same source...like the date or something?
Avatar of jjhj

ASKER

greedy

what i am thinking is that there will be on-going alternating caption changing every 24hrs.  the problem i see with a date related caption is that i can only have seven,  based on the week.  i would want approximately six months worth of message circling  every six months.

is it possble for the caption to be tied to each day of the month
without the year interfering.  

so that every january 1 wll have the same label caption and then
jan 2 will have a new label caption  , then jan 3 will have its own unique label caption   ect ect

if you give up i understand     mon
You know I've answered this question like three times now...AND YOU STILL HAVEN'T TOLD ME WHAT IT IS THAT YOU ARE WANTING TO DO WITH THIS PROGRAM.  But just in case you really need to make 60 compleatly difererent routines you can do this

Now take note because this is the second time I have told you this

this is done with 1 form with 1 TTimer droped on it...

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
    procedure DoTheTimer;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  MyTimerCounter : Integer;

implementation

{$R *.DFM}

//-------------------------------------------------------------------
procedure TForm1.FormCreate(Sender: TObject);
begin
  Timer1.Enabled := True;
  Timer1.Interval = 86400000;
  MyTimerCounter := 0;
end;

//-------------------------------------------------------------------
procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Timer1.Enabled := False; // this is to insure that the next event occures 24 hours after the
                           // one before has compleated.  If you want the next event to occur
                           // at the same time each day (the time that you started this program)
                           // then remove this line and the Timer1.Enabled := True that follows
  inc(MyTimerCounter);
  DoTheTimer;
  Timer1.Enabled := True; // remove this too for same time each day processing
end;

//-------------------------------------------------------------------
procedure TForm1.DoTheTimer;
begin
  Case MyTimerCounter of
    1 : {code for day 1}
    2 : {code for day 2}
    3 : {code for day 3}
    4 : {code for day 4}
    5 : {code for day 5}
    6 : {code for day 6}
    7 : {code for day 7}
    8 : {code for day 8}
    9 : {code for day 9}
    10 : {code for day 10}
    11 : {code for day 11}
    12 : {code for day 12}
    13 : {code for day 13}
    14 : {code for day 14}
    15 : {code for day 15}
    16 : {code for day 16}
    17 : {code for day 17}
    18 : {code for day 18}
    19 : {code for day 19}
    20 : {code for day 20}
    21 : {hopfully you get it by now}
    22 :
    23 :
    24 :
    25 :
    26 :
    27 :
    28 :
    29 :
    30 :
    31 :
    32 :
    33 :
    34 :
    35 :
    36 :
    37 :
    38 :
    39 :
    40 :
    41 :
    42 :
    43 :
    44 :
    45 :
    46 :
    47 :
    48 :
    49 :
    50 :
    51 :
    52 :
    53 :
    54 :
    55 :
    56 :
    57 :
    58 :
    59 :
    60 : {code for day 60 - set MyTimerCounter := 0 to start back at day 1}
  end;
end;

end.


NOW GIVE ME THE FRICKEN POINTS...AND TAKE A CLASS OR SOMETHING!

Avatar of jjhj

ASKER

greedily;

most people have bad mondays and smooth out during the week,  you however, well                 regain your strength

and franklky,  i'm shocked that you are "using" me for points
i thought we would be pen pails  or something

are letter bombs through e-mail possible??

ok bad joke

now i will definately give you your point tomorrow
no matter what

your program worked perfectly

but after
  Case MyTimerCounter of
     1: Label1.Caption:='new message1';
         Label2.Caption:='new message1';
     2: Label1.Caption:='new message2';
         Label2.Caption:='new message2';

      ect...
if i delete label 2  i'm fine

can i have two things happen on one day
like two caption changes

you be the man

and i am considering the class

and don't hurt anybody
jjhj



 




dude read a help file...if you want the 2 things to happen on a case condition, you must define the event block with a begin and a end

so take your code and do this -

Case MyTimerCounter of
     1: begin
          Label1.Caption:='new message1';
          Label2.Caption:='new message1';
        end;
     2: begin
          Label1.Caption:='new message2';
          Label2.Caption:='new message2';
        end;

and it's not that I am useing you form points...it's just you would be much better served if had some classes...but then again I never took a class I just read books and programed alot.  Yesterday I actually signed up for a basic C++ class only because I have to take it because my degree requires it...Ihave three years of college but it was back in 1990-93 and they only used C back then...then I left school in 93 to get money now I know more than the teachers but I figured I would take the class just in case I missed some little thing...and testing out of the class costs almost as much as taking it...anyway glad to help
damn it I didn't get to vent my anger in this message...hummm lets see...son of a bitch a fircken begin and a end holly crap hit the fricken F1 button it'll tell you right there...man what the hell...oh yes, much better...

Avatar of jjhj

ASKER

greedy;

what can i say
i'm going to miss being yelled at by e-mail

you did a great job

obviously, you're going to be successful at programing
send me some of your second million

i have more that i'm working on so....
if you are a glutton for punishment or
you want to take your frustrations out on someone

watch for my suped questions

signing off
jjhj
you can always just post questions as comments to this question and I'll get a email notice that something has been added.  I would give you my email address but I don't really want spam mail so I would have to send it to you in an encripted format...hummm lets see how should I encrypt this
the first letter in someone who raises pigs and cows (hint think Jones - maby a bad reference if your not from the midwest)
the first letter in a chick that dates only other chicks (hint - what they like to be called - and I don't think it's carpet muncher)
the first letter in a type of common big lizzard (no not a kamono dragon they are smaller than that)
the first letter in the type of pet that many people have (hint: it ****s in a litter box and goes meow)
the first letter in a type of animal that is common in australia (hint: hop hop)
the sixth letter in the word in the word chiglyack (a northern exposer reference)
ok that's the part before the @ just to be simple I will tell you now that the end is .c o m (without the spaces) for the domain you are going to have to get a reverse dictionary and look up the word that means "to rub up against people in a croud for sexual pleasure" I will give you a hint it rimes with a type of cheese that is very common...think house but like in the old days...but not a cabbin...it starts with a type of small bed that you might find in a hospital that has a sylable in it that is "ot"...ok now you are armed with the information that you need to decypher my email address this of coarse is only a VPO address so if it does start to get a bunch of email it will go away very fast...but rest assured that if something like that would happen you will anger the elite...I realy don't need to tell you what this means but it involves things like I will presonaly dedicate a portion of my T3 to DOS flood any conection that you will ever have into the internet...but anyway...why did you give me so many points what are you going to ask questions with now? Oh and by the way don't post a message here asking me if something is my email address...just send it and if it gets to me then your safe...voilating this will upset the elite too
oh well have fun...
chow
Avatar of jjhj

ASKER

greedy,

can you look at my question "the calendar"

i simply want a user to be able to keep a  running list of birthdays
that automatically show up on a calendar

or is it too much spam for ya
jjhj



Yeah, I'll look at it...should be really simple.  Do you want to use a database or just some csv (comma dilimited files) I'll go look at the question maby you have answered this there.

Avatar of jjhj

ASKER

greedy,
you spam muncher

i thought that a user could input on a data base grid
that in turn would be stored in a data base
that would be seen every year on a calendar

hey i think i'm on the wrong comment page
do you know 003?

and can 003 read this
no problem if can
 
i thought 003 dropped off the earth or something
or hates spam questions

if this doesn't clarify the question
i'm sure you'll let me know
plus do you answer these questions in your spare time or
is this some sort of strange job

i think i'm closing in on being an expert myself
you think so ??

jjhj
just answer them on my spare time...but I have a strange job too.  
Avatar of jjhj

ASKER

say what ?

where's the simp answer

dude
what's your email address and I'll mail it to you.
I've been really bust getting a spell checker to work in a cazy RTF component.  I don't have the source for the components so it's a REAL bitch to make it work...plus they are "limited" in there capabilities so I keep having to come up with extream work arounds...but I still got a little time last night to write a quick little thing that you might find usefull...do you have the Rx libraies installed on your computer yet.  if not I can send them too.  I use them in this little demo program so you'll need them if you want to change the code.
Avatar of jjhj

ASKER

quilting@frontiernet.net
Avatar of jjhj

ASKER

say what?
 QUILTING
@
FRONTIERNET.NET
why won't this pass?
Avatar of jjhj

ASKER

man o man o man

my e-mail message won't go through
but that's alright

just handle it like last time

being a spam in all
i'v got a long way to go, so easy on the terminalogy
you KNOW i don't know nuttin

and greedy
you've mellowed
what hoppin?
 
Avatar of jjhj

ASKER

man o man o man

my e-mail message won't go through
but that's alright

just handle it like last time

being a spam in all
i'v got a long way to go, so easy on the terminalogy
you KNOW i don't know nuttin

and greedy
you've mellowed
what hoppin?
 
Avatar of jjhj

ASKER

greedy o phily o boy

it looks like you made it through
how'd you do dat

this is a test only a test

anyway,  one way or another
give me some insight

jjhj
so you got the email then...I'll send the file in a few minutes..like maby 30...I've got a problem with a program again.
Avatar of jjhj

ASKER

greedy o phily o boy

it looks like you made it through
how'd you do dat

this is a test only a test

anyway,  one way or another
give me some insight

jjhj
why are you posting everthing twice?
Avatar of jjhj

ASKER

is everything posting twice always or just today?
Avatar of jjhj

ASKER

greedy
i know you're busy
but
from a dbgrid, give me an example of a program that takes a birthdate and a name in separate fields and posts to a calendar

and if possible , to alphabitize the name fields with corresponding  address as they are put in by user

now i know that there are programs out there that do it but i need my own

jjhj
Avatar of jjhj

ASKER

greedy,

if you got time check my question
"calendar"
jjhj