How to Add the time and date automatically to log files

How to Add the time and date automatically to log files

1

    Oct 31, 2006#1

    Notepad will insert the time and date automatically when you open the file if you initally create the file as follows.

    1. Create a blank text file with .LOG as the first line of the file, followed by a carriage return, and then save and close the file.

    Then you open the file with Notepad it appends the current date and time to the end of the file and places the cursor on the line after.

    How can this be done using UE?

    6,684586
    Grand MasterGrand Master
    6,684586

      Nov 01, 2006#2

      The following macro creates a new file with first line .LOG and second line with date and time in the format you have specified in the Regional and Language settings of Windows and then opens the Save As dialog.

      InsertMode
      ColumnModeOff
      HexOff
      NewFile
      ".LOG
      "
      TimeDate
      "
      "
      SaveAs ""


      If you want to append automatically current date/time to a file with the extension .log on every file load, use following macro specified to be executed on every file load:

      IfExtIs "log"
      Bottom
      IfColNumGt 1
      "
      "
      EndIf
      TimeDate
      "
      "
      EndIf

      If you want a customized date/time format for log files, specify first at Configuration - Directories the Template Directory.

      Then open Advanced - Display/Modify Templates, enter the template name, i.e. "Log Date/Time", press F1 to see help for this dialog and use the date/time format specifiers as described in the help to customize the date/time string. Then click button OK to save name and template "text" to template number 0. A file named Uetmplte.dat is created in the directory specified before and now always automatically loaded.

      In the 2 macros above replace the command TimeDate by Template 0.
      Best regards from an UC/UE/UES for Windows user from Austria

      1
      NewbieNewbie
      1

        Dec 22, 2006#3

        Folks,
        I want to run a macro on an existing file and then save it with a file name that includes the current date and time eg: "Order200612211531.csv"
        I know TimeDate inserts text into a file body but I want to include the current date and time into the SaveAs command. This is standard DOS stuff and must be a common requirement. Anyone know how to do this in UE? Eg:

        ===
        InsertMode
        ColumnModeOff
        HexOff
        UnixReOff
        NewFile
        TimeDate
        SaveAs "C:\temp\Order^TimeDate.csv"
        CloseFile

        ===

        cheers, Phil

        6,684586
        Grand MasterGrand Master
        6,684586

          Dec 22, 2006#4

          The easiest method is to create a template at Advanced - Display/Modify Templates with name "FileNameWithDateTime" with following content

          Order[DATE_USER]yyyyMMdd[DATE_USER_END][TIME_USER]HHmm[TIME_USER_END].csv

          Press key F1 when the dialog is open to see help about templates and what this string means.

          Remember the number of this template, for example 0 for your first template.

          But before you create the template, specify at Advanced - Configuration - Directories the Template Directory for the template file Uetmplte.dat.

          After you have created the template, you can insert this special date/time string with "Order" before and ".csv" after with a hot key assigned to the InsertTemplateX command, or with Advanced - Insert Template, or with Advanced - Individual Templates, or via the Template List (View - Views/Lists - Template List), or with a macro.

          Here is the macro which inserts temporarily at top of your already modified file the template, cuts it to user clipboard 9 to next save
          the file with this string in the file name. ^c is the place holder for the clipboard content as described in help about macro command SaveAs.

          InsertMode
          ColumnModeOff
          HexOff
          Top
          Template 0
          SelectToTop
          Clipboard 9
          Cut
          SaveAs "C:\temp\^c"
          CloseFile
          ClearClipboard
          Clipboard 0

          The big advantage of using a template instead of macro command TimeDate is that with a template you can define how the date/time string should look like. The TimeDate command inserts full date and time in the format specified in the Regional and Language Settings of Windows of the current user. And it's not a good idea to modify this Windows setting.
          Best regards from an UC/UE/UES for Windows user from Austria