Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


Write to a log file UDF

 Keywords: write log file logfile 

;*******************************************************************
;***** Function : F_WRITELOGFILE 
;***** Description : Write to a log file 
;***** log file is written when Logging=YesCreate or YesAppend!
;***** Release : 1.4
;***** Programmer : Theo Coolen 
;***** Returns : Always 0
;***** CATAGORY : Universal function 
;***** STATUS : Tested, OK
;*******************************************************************
#DefineFunction F_WRITELOGFILE(Logging,LocalLogFile,Glob_progpart,Glob_logmsg)

Logging=strUpper(Logging)

If Logging == "YESCREATE"
Tries = 0
FhandleLog = FileOpen(LocalLogFile, "WRITE")
while FhandleLog == 0 ;// if error try to open until it is ok
Tries = Tries + 1
FhandleLog = FileOpen(LocalLogFile, "WRITE") ;// get the handle until it succeed
beep
TimeDelay(3)
endwhile 
EndIf

if Logging == "YESAPPEND" 
Tries = 0
FhandleLog = FileOpen(LocalLogFile, "APPEND")
while FhandleLog == 0 ;// if error try to open until it is ok
Tries = Tries + 1
FhandleLog = FileOpen(LocalLogFile, "APPEND") ;// get the handle until it succeed
beep
TimeDelay(3)
endwhile 
Endif

a = TimeDate()
sub_LogMsg = strcat(a,": ")
part = Strfix("%Glob_progpart%"," ",25) ;// not longer than 15 characters for label in logfile

if IsDefined(Glob_logmsg)
final_Msg = strcat(sub_logMsg," %part%")
final_Msg = strcat(final_Msg,Glob_logmsg%j%)
FileWrite(FhandleLog, Final_Msg)
endif 

FileClose(FhandleLog)
return 0
#EndFunction
;*******************************************************************
;***** End of function F_WRITELOGFILE 
;*******************************************************************

;***************************************************************************
;* FUNCTION : F_WriteLogFileHeader 
;* DATE : 21 mei 2002 
;* PURPOSE : Writes the header for a logfile
;* AUTHOR : T. Coolen 
;* VERSION : 1.00 
;* INPUT : logfile and message 
;* RETURNS : always 0 
;* CATAGORY : Universal function 
;* STATUS : Tested, OK
;***************************************************************************
#DefineFunction F_WriteLogFileHeader(logfile,ProgramName,versie,devver,companyname,developer,Developdate)
F_WRITELOGFILE("YesCreate","%logfile%","Main"," ")
F_WRITELOGFILE("YesAppend","%logfile%","Main","*******************************************")
F_WRITELOGFILE("YesAppend","%logfile%","Main","* %ProgramName% : versie:%versie% build:%devver% started.")
F_WRITELOGFILE("YesAppend","%logfile%","Main","* Company : %CompanyName%.")
F_WRITELOGFILE("YesAppend","%logfile%","Main","* Developed by : %Developer%.")
F_WRITELOGFILE("YesAppend","%logfile%","Main","* Develop date : %DevelopDate%.")
F_WRITELOGFILE("YesAppend","%logfile%","Main","*******************************************")
F_WRITELOGFILE("YesAppend","%logfile%","Main"," ")
F_WRITELOGFILE("YesAppend","%logfile%","Main","If you are reading this file then you should ask yourself if you are allowed too?")
F_WRITELOGFILE("YesAppend","%logfile%","Main"," ")
return 0
#EndFunction
;*******************************************************************
;***** End of function F_WriteLogFileHeader 
;*************************************************