How to determine host name of active file opened via FTP in a macro?

How to determine host name of active file opened via FTP in a macro?

2
NewbieNewbie
2

    Nov 30, 2018#1

    Is there a way for a macro to determine the name of the host server for a file opened via FTP?  
    TIA.

    6,688587
    Grand MasterGrand Master
    6,688587

      Dec 01, 2018#2

      UltraEdit macros do not support variables. There can be used only ^s (selected text) and ^c (content of active clipboard) in some commands like Open (file open), SaveAs (file save as), Find, Replace, FindInFiles and ReplInFiles. In an UltraEdit macro it is only possible to use macro command CopyFilePath to copy full qualified file name to active clipboard, paste that string into active file with command Paste and use a regular expression Find or Replace to get or change the pasted string to host name of server.

      Here is an example macro code which puts just host name of current file into clipboard 9 for usage with ^c or pasting into file with Paste in syntax for UltraEdit for Windows < v25.00.

      Code: Select all

      InsertMode
      ColumnModeOff
      HexOff
      Clipboard 9
      CopyFilePath
      Top
      Paste
      "
      "
      SelectToTop
      PerlReOn
      Find MatchCase RegExp SelectText "S?FTP::\K([^/\\|]+)"
      Copy
      DeleteLine
      ... other macro commands ...
      ClearClipboard
      Clipboard 0
      For UltraEdit for Windows v25.00 or any later version the line with command Find must be with escaping \\ with one more backslash:

      Code: Select all

      Find MatchCase RegExp SelectText "S?FTP::\K([^/\\\|]+)"
      UltraEdit scripts support variables and therefore it is with just one line possible to get from string variable with full qualified file name of active file the host name part assigned to a string variable like sHostName by using:

      Code: Select all

      var sHostName = UltraEdit.activeDocument.path.replace(/^S?FTP::([^\/\\|]+).*$/,"$1");
      Best regards from an UC/UE/UES for Windows user from Austria

      2
      NewbieNewbie
      2

        Dec 03, 2018#3

        Thank you very much, Mr. Mofi. You gave me a great idea for using the clipboard. FYI, I use a macro to run a user tool which initiates a script that makes a backup copy of the saved FTP file. By adding CopyFilePath to the macro, the script can get the host name from the clipboard. Problem solved!