05-04-2007, 02:50 PM
on second thought; use this
function name: "anything you want it to be"
function name: "anything you want it to be"
;/
function ~s [flags] [$logfile] ;;flags: 1 date/time
;Writes s to the end of the log file but puts the string in front of the date/time stamp.
;s - string or number to write.
;logfile - file name. Default: _logfile (global variable, read more in QM help).
;If file size exceeds _logfilesize (global variable, default is 50 KB), removes first half (oldest data).
;EXAMPLES
;LogFile "string"
;int a=10
;LogFile a 1
if(!len(logfile)) logfile=_logfile
File f.Open(logfile "a+")
int i=f.FileLen
if(!_logfilesize) _logfilesize=50*1024
if(i>_logfilesize)
,f.SetPos(_logfilesize/2)
,f.ReadToStr(_s)
,f.Close
,f.Open(logfile "w")
,i=findc(_s 10)+1
,f.Write(_s+i _s.len-i)
if(flags&1) s.from(s "[]" _s.time("%c"))
f.WriteLine(s)
err+ end ES_FAILED