How to over-write values in a log file


Hi ,

I have a log file I am writing to during a process I am running. Each line
lists a table and a value at the end. The value will always be a 3 digit
number as in :

Start Log At 4:15 PM

Table1 026
Table2 056

What I need to do is update the value as the process runs. But I don't know
how many times the number will be updated. So what I want to do is write the
value, and then if it is updated, write the new value over the top of the
old one. How can I do this. I am using TextFiles and using Append to add to
the file. In the above example, if a new value for Table2 was received, I
want to over-write the 056 and replace it with 078 (or what ever). I will
only ever update the last table in the log file. Once I move to another
table, the previous table is finished with. And I'll write the value with
Write (and not WriteLn).

Any ideas how I can do this

Cheers,
Paul


Posted On: Tuesday 16th of October 2012 03:59:15 AM Total Views:  150
View Complete with Replies

RELATED TOPICS OF Delphi Programming PROGRAMMING LANGUAGE




Suggest expanding maximum *set* size from 2^8 to 2^16 values

Is it time to expand the maximum set size from the old set's maximum size of 2^8 values (requiring a maximum of 32 bytes) to a maximum size of 2^16 values (requiring a maximum of 8192 bytes) The set size has *not* grown in proportion to available memory or program complexity. The old set was invented when available memory was about 640 KB. Now, available memory is easily 1 GB. I believe that modern computers can easily support a maximum set size of 2^16 values, i.e. 8192 bytes, in size. Note that 640 KB / 32 Bytes = 20,000 1 GB / 32 Bytes = 31,000,000 1 GB / 8192 Bytes = 122,000 The new set would even allow defining tWideCharSet = set of WideChar; What are the backward compatibility problems --JohnH, 2008-08-07 PS: I just proposed such in QualityCentral report: http://qc.codegear.com/wc/qcmain.aspxd=65404
VIEWS ON THIS POST

140

Posted on:

Wednesday 19th September 2012
View Replies!

Is there a way to count the number of possible values of an enumeration?

Hi all. I'm wondering if there is a way to count the values of an enum type. For example the count of type TWeekEnum = (Mon, Tue, Wen, Thu, Fri, Sat, Sun); should result in 7.
VIEWS ON THIS POST

133

Posted on:

Thursday 20th September 2012
View Replies!

Assigned(_values:array of pointer) ?

Why no array function for Assigned() DH
VIEWS ON THIS POST

63

Posted on:

Monday 24th September 2012
View Replies!

movable type or wordpress blog

so which is better -- Dennis Landi http://www.dennislandi.com ied Data, Inc. http://www.allied-data.com Electron Server http://www.electronserver.com
VIEWS ON THIS POST

88

Posted on:

Wednesday 3rd October 2012
View Replies!

TFindDialog question

Colleagues, Not a cross-post; simply to say that I've asked a question over on ..vcl.components.using.win32, and I note that the activity seems fairly low over there. So, if anyone frequents this group and might be good enough to take a look, I'd be most grateful.
VIEWS ON THIS POST

106

Posted on:

Wednesday 3rd October 2012
View Replies!

Subrange Set property accepts enumerated values outside of subrange

I'm having problems with a field that is a set type. The set type is declared as a set of a subrange of an enumerated type. In my code if I try to add another value from the enumeration to the set, it compiles. My feeling is that because the value is outside of the subrange (and hence the allowable types in the set) it should not compile. Any views or explanations are welcome. D type TCTReason = (srStarted, srTimedOut, srTerminated, srSuspended, srResumed); TCTStatusFlag = srStarted .. srTerminated; TCTStatusFlags = set of TCTStatusFlag; .... TCTObject = class private FStatusFlags: TCTStatusFlags; public procedure Update; end; ..... procedure TCTObject.Update; begin // the following line compiles !! It shouldn't because srResumed is outside of the subrange TCTStatusFlag FStatusFlags := FStatusFlags + [srResumed]; end; David Moorhouse Moorhouse Works ltd www.moorhouse.co.nz
VIEWS ON THIS POST

133

Posted on:

Thursday 4th October 2012
View Replies!

Pasting into the FindDialog

I have a shortcut in the menu for CTRL-V to paste into a memo document. If the finddialog is open how can I get the CTRL-V to paste into the edit field in this dialog instead if it is active -- Best regards, Harold
VIEWS ON THIS POST

39

Posted on:

Friday 5th October 2012
View Replies!

How to show debugging values with mouseover?

What setting to I change to show variable values when I mouse over the code during debugging I had this working before, but changed something in the settings and can't remember what.
VIEWS ON THIS POST

138

Posted on:

Saturday 6th October 2012
View Replies!

CreateMessageDialog SetFocus to designated button

I have a need to use CreateMessageDialog passing Parent Control (Prnt) for manual positioning as well as passing a designated Button Caption (FocusCaption) in order to make said button the one focused on show. Obviously I cannot use the button's SetFocus method as the form is not visible at this stage. Can someone please show me how I can set the deed button as the focused object when shown -
VIEWS ON THIS POST

52

Posted on:

Saturday 6th October 2012
View Replies!

Manipulating FilterIndex of TSaveDialog at runtime.

Dear Expert Programmers, Like we are all familiar with word processor like Microsoft Word, what is the intellectual coding behind the saving dialog In Microsoft Word for example, let's run the program, write some few texts, then we try to save. For the file format we have the following to our dispositions: Filter Name Filter --------------- ----------- Text files(*.txt) *.txt Word files(*.doc) *.doc Rtf files(*.rtf) *.rtf Okay, we open the save-as dialog box. We find ourselves in the "Text files" instance. We write the file name, say,"output" without the extension. Microsoft Word saves to "output.txt". Still we change the Filter Name, say, to "Word files" instance and we just write "output". Again the program saves to "output.doc". Likewise, still we change the Filter Name, say, to "Rtf files" instance and we just write "output". Again the program saves to "output.rtf". What are the intellectual coding behind this scenario As anyone done this before in Delphi 5 A working (code for the task put forward above) will be greatly appreciated. Many
VIEWS ON THIS POST

49

Posted on:

Saturday 6th October 2012
View Replies!

SaveDialog box and its intelligent implementation

Dear Colleagues, On my main form, I have (in addition to others components) a TChart1, Memo1, SaveDialog1 and a button. The Memo1 is a place-holder for some numerical output of a calculation while the TChart1 does the drawing. The output of the calculation must either be saved in text or graphic format by the help of the OnClick event of the button using the intelligence of SaveDialog box. In my present implementation/coding (Delphi 5 environment, see the code below), the user of the program is forced to add the infix of the file format to determine which kind of file to save, namely output.txt or myfile.bmp. If the user just writes, say "output", the program raises an error message. How can I put some intelligence into the coding, so that the outcome of the resulting output depends on recently-focused Filter of the SaveDialog1-box. I have as Filters of the Savedialog1 box the following: *.txt *.bmp *.wmf *.emf That is, if the user just writes "output" when the Filter "*.txt" is focused/active, the resulting file should be: output.txt. Likewise if the user just writes "output" when the Filter "*.wmf" is focused/active, the resulting file name should be: output.wmf. This kind of implementation is incorporated into some programs such as Microsoft Word, Microsoft Picture It! Photo 7.0; etc. Please, can anyone provide me with an intelligent example-code how this issue can be solved. Many thanks in advance. With best regards, Alex Siron from FINLAND procedure TForm1.SaveAsToolButtonClick(Sender: TObject); var F: System.Text; i: Integer; S: String; begin if SaveDialog1.Execute then with SaveDialog1 do begin S:=UpperCase(ExtractFileExt(FileName)); if S='.TXT' then begin AssignFile(F,FileName); Rewrite(F); for i:=0 to Memo1.Lines.Count-1 do WriteLn(F,Memo1.Lines[i]); CloseFile(F); end else if S='.BMP' then Chart1.SaveToBitmapFile(FileName) else if S='.WMF' then Chart1.SaveToMetafile(FileName) else if S='.EMF' then Chart1.SaveToMetafileEnh(FileName) else MessageBox(Handle, 'Valid file extensions are ''.txt'',''.bmp'',''.wmf'' and ''.emf''', 'Error', MB_ICONSTOP OR MB_OK); end; end;
VIEWS ON THIS POST

77

Posted on:

Saturday 6th October 2012
View Replies!

[HCI] reduce logging time (log to stream)

I have a server with many clients,the server use following function for logging events of clients, but my communication speed reduced during using this method of logging ! How can i speed up my logging ! Dont forget i can not buffer logs in my server buffer, because in each time(T1), server can close or throw error and i need log of T1. Notes: 0.My server system have 2 powerful processors and all of date convertion in this function can execute immediately. 1.logf is a global variable (logf:TFileStream); 2.onChangeDay change output file in end of day. 3.function parameter is string,because input parameter can be more than 255 characters. 4.this function must be available from multithreads.for this reason im using critical sections. 5.output of logf are growing less than harddisk speed, but also is heavy (in sometimes that is traffic on the server more than 10 mb per minutes). 6.output file has text file view. procedure TCommform.addlog(s:String); var str:String; const endofLine:string=#13+#10; begin if Assigned(LogCheckBox) then if LogCheckBox.Checked then begin try EnterCriticalSection(CritSect); CurrentDay:=DayOf(now); if currentDayOldDay then onChangeDay(); str:=convToSTDDate(now,'/',':')+':'+s; if realtimeLoging then begin logf.Write(Pointer(str)^, Length(str)); logf.Write(endofLine[1],2); end; oldDay:=CurrentDay; finally LeaveCriticalSection(CritSect); end; end; end;
VIEWS ON THIS POST

46

Posted on:

Saturday 6th October 2012
View Replies!

Vista blocks modal login window

: I have a delphi app standard database application. 1) My main form is created 2) It calls a modal login window 3) Once the user logs in they are put in the main window. I have successfully installed to maybe 25 to 50 Vista machines no problem. Today, we installed on a Vista machine and we have big problems. About 95% of the time, our little login window never appears. You cant minimize or close the application - the only solution is to use the task manager to kill it. About 5% of the time the app launches flawlessly. Anybody got any experience with this \t Any input on how to diagnose or solve this \t I am very confident that is is some MS Vista issue. Thank you Neil Frustrated With Vista Wondering how Miscorosft botched it so bad Thank you
VIEWS ON THIS POST

29

Posted on:

Monday 8th October 2012
View Replies!

BDS2006: Screen.Monitors[] corresponds not to picture "Windows ScreenDisplay Settings"-Dialog

, I just created a list of all my Monitor-Coords via Screen.Monitors[]. But when I compare the result with the picture of "Windows Screen Display Settings"-Dialog then here is one bug, that means two Monitors have the wrong number list in the picture (or in my list). Any comments
VIEWS ON THIS POST

64

Posted on:

Monday 8th October 2012
View Replies!

how to select a directory via TOpenFile dialog?

I'd like to let user to provide a way to select a directory using windows explorer style dialog in which a user would be able seeing all files, changing existing and creating new directories.
VIEWS ON THIS POST

108

Posted on:

Tuesday 9th October 2012
View Replies!

how to select a directory via TOpenFile dialog?

I'd like to let user to provide a way to select a directory using windows explorer style dialog in which a user would be able seeing all files, changing existing and creating new directories.
VIEWS ON THIS POST

57

Posted on:

Tuesday 16th October 2012
View Replies!

Books with good technology stories

Hi , 1. Geoffrey Moore. Crossing the Chasm. Marketing and Selling High-Tech Products to Mainstream Customers. PerfectBound, 1991 I am currently reading this book and can say that it's a great book about technology marketing and about marketing in general. An added bonus is that the book contains many great examples with references to companies like Oracle, Microsoft, Apple and how they took their products to the top of the competition. Anybody has more good books to add to the list
VIEWS ON THIS POST

29

Posted on:

Tuesday 16th October 2012
View Replies!

Embarcadero's Director of Product's Blog

http://metafrequency.blogspot.com/20...-codegear.html -- Nick Hodges Delphi Product Manager - CodeGear http://blogs.codegear.com/nickhodges
VIEWS ON THIS POST

68

Posted on:

Tuesday 16th October 2012
View Replies!

Subrange Set property accepts enumerated values outside of subrange

I'm having problems with a field that is a set type. The set type is declared as a set of a subrange of an enumerated type. In my code if I try to add another value from the enumeration to the set, it compiles. My feeling is that because the value is outside of the subrange (and hence the allowable types in the set) it should not compile. Any views or explanations are welcome. D type TCTReason = (srStarted, srTimedOut, srTerminated, srSuspended, srResumed); TCTStatusFlag = srStarted .. srTerminated; TCTStatusFlags = set of TCTStatusFlag; .... TCTObject = class private FStatusFlags: TCTStatusFlags; public procedure Update; end; ..... procedure TCTObject.Update; begin // the following line compiles !! It shouldn't because srResumed is outside of the subrange TCTStatusFlag FStatusFlags := FStatusFlags + [srResumed]; end; David Moorhouse Moorhouse Works ltd www.moorhouse.co.nz
VIEWS ON THIS POST

164

Posted on:

Tuesday 16th October 2012
View Replies!

Vista blocks modal login window

: I have a delphi app standard database application. 1) My main form is created 2) It calls a modal login window 3) Once the user logs in they are put in the main window. I have successfully installed to maybe 25 to 50 Vista machines no problem. Today, we installed on a Vista machine and we have big problems. About 95% of the time, our little login window never appears. You cant minimize or close the application - the only solution is to use the task manager to kill it. About 5% of the time the app launches flawlessly. Anybody got any experience with this \t Any input on how to diagnose or solve this \t I am very confident that is is some MS Vista issue. Thank you Neil Frustrated With Vista Wondering how Miscorosft botched it so bad Thank you
VIEWS ON THIS POST

27

Posted on:

Tuesday 16th October 2012
View Replies!