: This message was edited by zibadian at 2003-10-30 14:27:14
: : : : : Hi
: : : : : I would like to be able to change a Memo's lines programmatically using a Timer.
: : : : : I want to be able to switch between
: : : : : Memo1.lines.loadfromfile('Items.txt') and
: : : : : Memo1.lines.loadfromfile('Details.txt')
: : : : : Can I do this using a Timer? or is there another way?
: : : : :
: : : : : Cheers
: : : : :
: : : : : Mike
: : : : :
: : : : Sure you can. Set the interval property to the desired time and put the code above inside an OnTimer event handler. You might have to do a clear in between loading the the two text files. I'm not sure about that, but it can certainly be tested easily enough. HTH
: : : :
: : : Thanks for the swift response
: : : If I want a label to blink I can code something like...
: : : Label.visible:=not label1.visible
: : : and put that code inside a Timer.
: : : How can I put the Lines.loadfromfile stuff in similar fashion so that the Timer will change the file used each time?
: : : Sorry if I've explained this badly.
: : : Mike
: : :
: : The label thing should work. If I were going to code the file loading, I think I'd make an array of string constants to hold the filenames and use a counter to loop thru it. That's just one way. There a lot of others that you or others would think of.
: In case of such an array, you can use the Tag property as the counter. The code itself is quite simple. Also you don't need to clear the lines before loading, since loading replaces the entire contents.
: If you are just switching between two filenames, then you can also use a simple if-then statement. Here's an example:
: if Timer1.Tag = 0 then begin
: Timer1.Tag := 1;
: end else begin
: Timer1.Tag := 0;
: You can also use a case-of in this fashion:
: case Timer1.Tag of
: 0: Memo1.Lines.LoadFromFile('file1.txt');
: 1: Memo1.Lines.LoadFromFile('file2.txt');
: 2: Memo1.Lines.LoadFromFile('file3.txt');
: if Timer1.Tag = 2 then
: Timer1.Tag := 0
: Timer1.Tag := Timer1.Tag + 1;
: This is slightly shorter to code than a complete array, but is less flexible.
Yes, this is just what I need. Thanks