Tapatalk

touch macro - update last modification file time without file contents modification

touch macro - update last modification file time without file contents modification

7

    Jun 14, 2017#1

    HELP! I cannot find a way to write an UE macro that functions like the Unix touch command. I want to assign this macro to a key. (The Unix touch command updates the date modified time stamp of a file.) This need was induced because UE does not save the current file if it has not been modified. I am a Windows 10 user of UE. I am new to UE.

    I have tried various uses of SaveAs. Example: CopyFilePath --> SaveAs "^c". I get a message "CTags file does not exist. Please check CTAGS options." To say this message is opaque would be vast understatement. Besides, even if this worked I am worried that there would be a pesky dialog about "file already exists", which would not be acceptable.

    Thanks for any help.

    6,685587
    Grand MasterGrand Master
    6,685587

      Jun 14, 2017#2

      Which version of UltraEdit do you use?

      I tested the following macro with UE v24.10.0.24 on Windows 7 and v22.20.0.49 on Windows XP:

      Code: Select all

      CopyFilePath
      SaveAs "^c"
      The file name of active file was C:\Temp\Test.tmp. On every execution of the macro by hotkey the last modification time of the file was updated and no prompt was shown. The prompt is only displayed on manual execution of Save As and a file with that name exists already.

      Better would be using this code with copying file name with path into user clipboard 9 and restore unmodified Windows clipboard before exiting macro.

      Code: Select all

      Clipboard 9
      CopyFilePath
      SaveAs "^c"
      ClearClipboard
      Clipboard 0
      Best regards from an UC/UE/UES for Windows user from Austria

      7

        Jun 14, 2017#3

        Thanks so much! The version of UE is 23.20. I cannot figure out how to be more specific about version.

        I copied your code and no success. Does it have anything to do with assigning the key as F11?

        6,685587
        Grand MasterGrand Master
        6,685587

          Jun 14, 2017#4

          In ribbon mode (default since UE v23.00) there is on ribbon tab File at bottom About and on right side of the ribbon tabs bar Support which on left click opens a popup menu with last item being also About..

          In toolbar/menu mode with contemporary menus there is in menu File the menu item About and also in menu Help.

          In toolbar/menu mode with traditional menus there is in menu Help the menu item About.

          The text displayed in About dialog window above the button can be completely or partly selected and copied with Ctrl+C to Windows clipboard. So it should be no problem for every user to copy the exact version of used UltraEdit.

          When a macro file with 1 or more macros is loaded and a loaded macro has a hotkey like F11 assigned, this macro hotkey should take precedence over hotkeys assigned to internal commands of UltraEdit.

          But it looks like this is not the case in used version of UltraEdit or more likely the macro is not loaded automatically on startup of UltraEdit. For that reason I suggest to open Advanced - Settings/Configuration - Key mapping. In the Commands list scroll down to command Find symbol, select it with left mouse button, click on button Remove and close configuration with Save.

          The error message because of execution of command Find symbol with not using Ctags at all should not occur anymore and instead the macro should be executed when loaded.

          Note: The macro file containing the macro to touch active file must be configured to be automatically loaded on startup of UltraEdit to make it possible to execute the macro with key F11 without an explicit manual load of the macro. On using ribbon mode select ribbon tab Advanced, click in group Macro on small down arrow right of Configure and click on popup menu item Set macro for auto-load. The specified macro file can contain more than 1 macro.
          Best regards from an UC/UE/UES for Windows user from Austria

          7

            Jun 15, 2017#5

            Thanks for all the time you are spending on my problem. I understand all that you said above with one exception, which is key to my decision to commit to UE: How do I create a file with multiple macros in it? I simply cannot figure this out as a result of multiple searches and it was only through tiny little bread crumbs, including those you left, that I was able to detect that such a capability existed. I cannot remember whether I mentioned this: I am a 30+ year user of XEdit/KEdit. There is a lot to like about UE, but I have a hard time understanding all the heterogeneity of customization. My objective, because I travel a lot for my work, is to use the exactly the same configuration of my text editor across a desktop and notebook. Because of the heterogeneity of methods I find this very difficult under UE. (For example why is it not possible to create key bindings using the JavaScript engine?)

            In any case, what seems to be my current blocking issue it to learn how to create a single file containing multiple macros. Please just point me to a place where I can find out how to do this.

            326
            Basic UserBasic User
            326

              Jun 15, 2017#6

              If you have one macro loaded you can record / define a new macro. Once you are done you can save the macros (now you should have two) to a new Macro file via the Macro menu. You can now also set that Macro file to be automatically loaded upon startup of UE. Macro menu, set Auto load and select the Macro file you've just saved.

              Just keep adding new Macros this way and save them to the same Macro file as above and new Macros automatically be loaded upon startup.

              If you do view, view/lists, Macro list you will get a window with a list of all Macros and you can either double click on them to run them OR right click, edit to edit them.

              I hope this is useful.

              6,685587
              Grand MasterGrand Master
              6,685587

                Jun 15, 2017#7

                First, macros and scripts are designed in UltraEdit for doing something on files, not for customizing or configuring UltraEdit itself. What happens when macros and script become to powerful can be seen on Visual Basic macros/scripts, ActiveX, JScript, etc. – they become a big security risk. In my point of view it is good that UltraEdit macros and scripts can be used only for modifying files although that is already problematic because it is possible to modify every file with write access.

                Ribbon mode

                Select ribbon tab Advanced and look on items in group Macro. There is the down arrow right of item Load with the two items Load... to load a macro file with 1 or more macros replacing all currently loaded macros and Load and append to existing with loading all macros in a macro file with appending them to currently loaded macros.

                The list of currently loaded macros can be seen by clicking on down arrow right of item Configure and clicking on Configure macros. In opened Modify Macro dialog it is possible to delete and rename macros, change their hotkeys or chords and change the two properties for each loaded macro.

                To run one of the loaded macros either click on down arrow right of item Play macro and click on Play multiple times or switch to ribbon tab Layout and check Macro list to open the Macro List view. Like all other views also this view can be configured to be docked on any side without or with auto-hiding or being floating view. And like all other views it is also possible to assign a hotkey for this view in key mapping configuration dialog to quickly open/close it by key. A macro listed on Macro List view can be executed one times by double clicking on it. The Macro List view has also the context menu item Modify Macro to open the Edit/Create Macro dialog.

                There are three possibilities to create a macro:
                • Quick record a macro by pressing Ctrl+Shift+R or clicking on down arrow right of item Record and clicking on Quick record. Quick recorded macros have never a name, have macro property Show cancel dialog for this macro not checked and macro property Continue if search string not found checked. Those properties can be later modified.
                • Record a macro with first opening Macro Definition window to define macro name and all the other properties before recording starts by clicking on down arrow right of item Record and clicking on Define and record...
                • Create a new macro by opening Edit/Create Macro dialog for example with clicking on down arrow right of Configure and next on Edit macro.... This dialog has the button New macro to create a new macro for example with macro code posted in this forum.
                A recorded or manually created macro is always appended to list of currently loaded macros as long as its name is unique in list of currently loaded macros. This means quick recording multiple macros requires giving each quick recorded macro a name before quick recording next macro as otherwise an already quick recorded macro is replaced on starting a new quick recording. That automatic replacement is of course very often very useful when the quick recorded macros are needed only temporarily for current editing of a file and do not need to be saved for future use.

                By clicking on down arrow left of Configure and next on Save all macros all currently loaded macros are saved into a specified macro file. On loading such a macro file all the binary compiled macros inside are loaded at once.

                Last by clicking on down arrow left of Configure and next on Delete all macros it is possible to delete all currently loaded macros from memory for example to create a new set of macros being stored in a new macro file.

                Toolbar/menu mode with contemporary menus

                This GUI mode has the same items as the ribbon mode. A ribbon tab is a main menu in this mode. Items on a ribbon tab are menu items in this GUI mode. A popup menu opened in ribbon mode on clicking on down arrow of an item is a submenu in this GUI mode.

                For that reason everything written above for ribbon mode exists also in toolbar/menu mode with contemporary menus with exactly the same names. All macro related items are in menu Advanced with the exception of menu item Macro list to toggle visibility of the Macro List view being located in menu Layout as in ribbon mode.

                Toolbar/menu mode with traditional menus

                This GUI mode has the menus and menu items like before UE v23.00 introduced the ribbon mode and the toolbar/menu mode with contemporary menus.

                This is my preferred GUI mode because I'm very familiar with this menu structure and nearly every command can be executed in this mode with at least one less click than in the other two modes. This fact can be easily seen also on macros management.

                There is the main menu Macro with all the commands as explained above to manage macros, but available directly in this menu and not in submenus or popup menus. The menu items have a little bit different name, but those usually longer menu item names are usually more meaningful than in the other two GUI modes.
                Best regards from an UC/UE/UES for Windows user from Austria

                7

                  Jun 17, 2017#8

                  Thanks for all your help. My problem got solved. UE support discovered I had suppressed temporary files and that gave me false signals about whether my touch macro was working. In any case my skills at creating macros to customize my keys and allowing this customization to be shared between my two computers now works have resulted in much joy (relatively speaking).