try
get_system_time (MSecond, Second, Minute, Hour, Day, YDay, Month, Year)
DateTime := Year+'-'+Month$'.2'+'-'+Day$'.2'+' '+Hour$'.2'+':'+Minute$'.2'+':'+Second$'.2'+':'+MSecond$'.3'
DirPathFirst := 'D:\\HalconException\\'
file_exists (DirPathFirst, bFileExists)
if (not bFileExists)
make_dir (DirPathFirst)
endif
DirPathSecond := 'D:\\HalconException\\'+Year+'_'+Month$'.2'+'_'+Day$'.2' +'\\'
file_exists (DirPathSecond, bFileExists)
if (not bFileExists)
make_dir (DirPathSecond)
endif
FilePath := DirPathSecond+Str_FileName+'.log'
file_exists (FilePath, bFileExists)
if (bFileExists)
open_file (FilePath, 'append', pFileHandle)
else
open_file (FilePath, 'output', pFileHandle)
endif
Str_Msg := DateTime +':' +Str_Msg+'\n'
fwrite_string (pFileHandle, Str_Msg)
close_file (pFileHandle)
catch (Exception)
endtry
return ()