News:

Function Finder  Find all the functions within source code files

Main Menu

WriteToLog (log file) function

Started by kevin, June 07, 2014, 05:18:28 AM

Previous topic - Next topic

kevin

   WriteToLog function

      This function can be placed throughout a program to drop messages out to disk, common known as a log file.  


      Commands used;  WriteNewFile , OpenNewFile, #Print


PlayBASIC Code: [Select]
   global WriteToLog_Filename$   =currentdir$()+"MyLogFile.txt"



WriteToLog("Start Of Log")
WriteToLog("Hello World")
WriteToLog("end.")





Psub WriteToLog(Message$)


local LogFile$=WriteToLog_Filename$
local Fh,size
if fileexist(logfile$)=false

fh=WriteNewFile(LogFile$)
if fh
writestring fh,Message$
closefile fh
endif

else

size=filesize(logfile$)
fh=OpenNewFile(LogFile$)
if fh
writestringat fh,size,Message$
closefile fh
endif

endif

#print "WriteToLog:"+ Message$

EndPsub





  Related File links:

     - Load File To String & Save String As File
     - Encode File  / Hide File Contents / Xor Encryption
     - Buffered file copy (copy data in blocks)
     - Scan and Backup Media (Work In Progress)