Copying specified columns

Copying specified columns

3
NewbieNewbie
3

    Jul 27, 2004#1

    I need a macro that can copy selected columns from a file (column numbers 267 to 278) and paste into a new empty file. Shouldn't be too difficult right? I just can't work out the syntax for this program. Thanks.

    6,675585
    Grand MasterGrand Master
    6,675585

      Jul 30, 2004#2

      After selecting the columns execute following macro:

      InsertMode
      ColumnModeOn
      HexOff
      UnixReOff
      Copy
      NewFile
      Paste

      Or do you want that the macro selects the column first. That would be more difficult, but can also be solved with a few tricks.
      Best regards from an UC/UE/UES for Windows user from Austria

      3
      NewbieNewbie
      3

        Aug 03, 2004#3

        Is there a command to select columns 267 to 278 that I could put in front of the code you have suggested.

        (the Ultraedit equivalent to columns(267:278).select)

        This would allow me to open the files and run the macro without manually selecting the columns.

        Thanks Al.

        6,675585
        Grand MasterGrand Master
        6,675585

          Aug 03, 2004#4

          UltraEdit v10.10 has no macro command to go or select a specified column. So cursor moves are needed in the macro to do that.

          First, I don't know, if the first line of your files have always at least 267 characters. If so, you can use Macro 2, which does not modify the source file. Macro 1 inserts a line with 267 spaces at the top of the source file. You have to expand the Replace command of Macro 1 with additionally 266 spaces before ^p.

          After setting the cursor to column 267 with one of these methods, column mode is activated and everything to the end of file is selected. Because I don't know if your files end with a linefeed, the macro sets the cursor to column 1 of the last line.

          Now 278 Key RIGHT ARROW are necessary in both macros to set the cursor to column 278 of the last line while selection mode is still active. Insert in both macros additionally 277 Key RIGHT ARROW.

          The correct columns are now selected and copied to the new file.

          In Macro 1 the inserted line with spaces is removed in the source and new file. So the data in the new file is correct and the source file is modified but has the exact contents before execution of the macro.

          Macro 1
          InsertMode
          ColumnModeOff
          HexOff
          UnixReOff
          Top
          Find RegExp "%^(*^)$"
          Replace " ^p^1"
          Top
          Key END
          ColumnModeOn
          StartSelect
          SelectToBottom
          Key HOME
          Key RIGHT ARROW
          Copy
          EndSelect
          ColumnModeOff
          Top
          StartSelect
          Key DOWN ARROW
          EndSelect
          Key DEL
          NewFile
          Paste
          Top
          StartSelect
          Key DOWN ARROW
          EndSelect
          Key DEL

          Macro 2
          InsertMode
          ColumnModeOff
          HexOff
          UnixReOff
          Top
          Loop
          Key RIGHT ARROW
          IfColNum 267
          ExitLoop
          EndIf
          EndLoop
          ColumnModeOn
          StartSelect
          SelectToBottom
          Key HOME
          Key RIGHT ARROW
          Copy
          EndSelect
          ColumnModeOff
          Top
          NewFile
          Paste
          Top
          Best regards from an UC/UE/UES for Windows user from Austria

          3
          NewbieNewbie
          3

            Aug 09, 2004#5

            Mofi, Thanks for your help on this, I could not get either of your macros to work but in the process found this code does the trick. It would be nice if it 'copied' rather than 'cut' from the source file but I can live with that.

            Cheers,
            Al.

            ColumnModeOn
            GotoLine 3
            Loop 266
            Key RIGHT ARROW
            EndLoop
            ColumnCut 11
            ColumnModeOff
            NewFile
            Paste
            ColumnModeOn
            Top