2022-01-04 halcon日志保存

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 ()

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容