ST3VO
asked on
Save files change history?
Hi all,
Suppose I saved the contents of a tmemo as a text file ....
Then another 30 minutes later (just an example)
Then my computer freezes and a lost my current work ...
How can I open the latest version saved by code?
I could save the filename with a date/time in the filename but how do I get the code to know which one it has to open without me having to check the datetime in the filename?
For example ... if the file is called:
project1
then I'd like to add a "-" (without the quotes) and then the datetime stamp included in the filename...
Then if I open Project1 .... the code checks the latest and opens that one....
Hope this makes sense.
I'm opened the suggestions if this is not the best way to do it.
thanks
st3vo
Suppose I saved the contents of a tmemo as a text file ....
Then another 30 minutes later (just an example)
Then my computer freezes and a lost my current work ...
How can I open the latest version saved by code?
I could save the filename with a date/time in the filename but how do I get the code to know which one it has to open without me having to check the datetime in the filename?
For example ... if the file is called:
project1
then I'd like to add a "-" (without the quotes) and then the datetime stamp included in the filename...
Then if I open Project1 .... the code checks the latest and opens that one....
Hope this makes sense.
I'm opened the suggestions if this is not the best way to do it.
thanks
st3vo
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In the code I've posted you can open the last created Project1-whatever just using the form 'c:\somedir\Project1*.*'
This means that the TSearchRec use Project1*.* as filter, then the bubble sort return the most recent, that is the newest
This means that the TSearchRec use Project1*.* as filter, then the bubble sort return the most recent, that is the newest
ASKER
Hmm...I just don't get the call example..
OpenMostRecent(GetMostRece nt('c:\som edir\Proje ct1*.*')); ....
Is it something like:
Var thefile:string;
begin
thefile :=OpenMostRecent(GetMostRe cent('c:\s omedir\Pro ject1*.*') );
memo1.lines.loadfromfile(t hefile);
????
OpenMostRecent(GetMostRece
Is it something like:
Var thefile:string;
begin
thefile :=OpenMostRecent(GetMostRe
memo1.lines.loadfromfile(t
????
OpenMostRecent is a dummy function that i've hoped you might have created.
Forget that :)
Well, you should finally use this method:
Memo1.lines.loadfromfile(G etMostRece nt('c:\The DirWhereYo uAreSaving \Project1* .*));
Of course change TheDirWhereYouAreSaving with the right directory where the files are stored
Forget that :)
Well, you should finally use this method:
Memo1.lines.loadfromfile(G
Of course change TheDirWhereYouAreSaving with the right directory where the files are stored
ASKER
Great! Thanks :o)
ASKER
e.g: Project1 etc.... The filename could have a "-" after the main name to help .....
So I could have:
Project1-somethinghere.txt
Project1-somethingelse.txt
etc...
Then I select to open Project1 and the code reads Everything before the "-" (for example) and then opens the newest one depending on datetime stamp for example?
You know what I'm after?