Copy and Pasting Blocks of data

Home Forums Multi-Edit User Created Macros Copy and Pasting Blocks of data

This topic contains 11 replies, has 132 voices, and was last updated by  JRushmeyer 4 years, 9 months ago.

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #3008

    JRushmeyer
    Participant

    OK….I am missing something stupid somewhere. I want to copy a line of text from the file I am in to another file. I can open the other file with no problem but it doesnt copy the text. The only thing it copies is the data that is in the buffer when I selected some text using the mouse. The code is below

    *************************************
    VOID Load_Test()
    {
    int han;
    TOF;
    Home;
    Block_Begin;
    /* rm("MarkBlck"); */

    EOF;
    Block_End;
    Copy_Block; /* supposedly I have copied the data to the buffer but it isnt happening */

    Return_Str = "C:\\DATA\\Test_2.txt";
    RM("LDFILES");
    Move_Block; /* I originally had COPY_BLOCK here */

    /* I remmed out the rest just to see if I could get the text into the TEST_2.TXT file */

    /*
    EOF;
    Down;
    Copy_Block;
    Save_File;
    S_Close_File(han);
    */

    /* —————–11/16/2014 3:58PM—————-
    Paste in the data
    ————————————————–*/
    }

    **************************************************************************************

    Any help would be appreciated!!!
    Thanks
    John Rushmeyer

    #9720

    Clay Martin
    Keymaster

    Hi,
    Try using MarkBlck() instead of block_begin. Also a good way to see if the block was loaded into the clipboard is run the first part of the macro (up to copy_block) then manualy open a window and try to paste. You may also want to change the copy_block to rm("BlockOp /BT=0");. Is your new window opening (from the ld files) and is the focus on that window?

    Thanks,
    Clay

    #9722

    JRushmeyer
    Participant

    Hi Clay
    Thanks for the quick reply again. I was working on this macro around the same time I saw your reply posted. The answer to your questions is:

    Yes the file was opened.
    Yes the cursor was at the home position (top left).

    I also tried you suggestion about manually opening a file and manually pasting into it….and it didnt work. I was reading the post from shrikes about TextToBuffer & BufferToText (I dont know how I missed that before) to see if it was any help. I will experiment with that later today. FYI – I boiled down my code to see if it helps diagnose the problem

    ************************************
    VOID Copy_Test()
    {
    int han;
    TOF;
    Home;
    rm("MarkBlck");
    EOF;
    Return_Str = "C:\\DATA\\Test_2.txt";
    RM("LDFILES");
    rm("BlockOp /BT=0");
    }
    ********************************************
    In this case I just highlighted the whole file (which is one line of data anyway). The line of data does get highlighted but again what gets pasted into the file is the last thing I manually highlighted and copied.
    So, anyway, thanks for your suggestions to this point and anymore will be appreciated!!
    John

    #9723

    Clay Martin
    Keymaster

    Hi,
    In Tools-Customize-Editing-Blocks what do you have for the following settings?
    Turn block highlighting after copy
    Turn block highlighting after paste
    persistent blocks

    And what are the settings in Tools-Customize-Editing-Clipboard?

    Are you using the bookmarks pane?

    After you run you mac, try Edit-Show Buffer, what do you see?

    May have been a typo on your part but your trimmed down macro seems to be missing Block_end.

    Thanks,
    Clay

    #9724

    JRushmeyer
    Participant

    Dang Clay…that was fast. I checked my settings and:

    Turn block highlighting after copy ………. I did NOT have that selected
    Turn block highlighting after paste ……… I DID have that selected

    persistent blocks ………………I did NOT have that selected

    And what are the settings in Tools-Customize-Editing-Clipboard?
    I have "Show paste buffer when copying.…………Selected
    Standard copy uses the paste buffer …………………….Was NOT Selected

    I ran the macro and did the Edit/Show Buffer and it showed something I had manually highlighted and Copied before….the text that was highlighted via the macro
    was not in the buffer!

    Oh….this may not mean anything OR it may mean EVERYTHING. I am running Brief Emulation. Could that be at the root of this issue?

    Thanks again

    John

    #9725

    Clay Martin
    Keymaster

    Hi John.
    Did your macro have the block_end? Also you want to do the copy before the ldfiles. Brief emu only changes the keystrokes that do things, not the commands. You might try this with Standard copy uses the paste buffer selected.

    Thanks,
    Clay

    #9726

    JRushmeyer
    Participant

    Clay

    Well, still no luck. I will hack around a little tomorrow and see what happens. Here is what I ended up with
    ******************************
    VOID Copy_Test()
    {
    int han;
    TOF;
    Home;
    rm("MarkBlck");
    EOF;
    Block_End; /* added this per suggestion */
    rm("BlockOp /BT=0"); /* put before the LDFILE as you suggested */
    Return_Str = "C:\\DATA\\Test_2.txt";
    RM("LDFILES");
    }

    **************************************

    I checked the buffer again and it is still holding the last thing I highlighted and copied prior to running the macro.
    Have a good day.

    John

    #9727

    JRushmeyer
    Participant

    Clay

    Well I may be making some headway. First, here is the code I boiled down to

    ********************************************
    VOID Copy_Test()
    {
    int han;
    TOF;
    Home;
    rm("MarkBlck");
    EOF;
    rm("BlockOp /BT=0");

    /* I deleted the rest that I remmed out to lessen the confusion */
    }

    ***************************************************************************************
    This bit of code actually DOES copy the whole file (which is fine for now…like I said the actual file contains one line of data anyway) and pastes it back into the SAME file. (so if the file had two lines of data it now has four lines of data). So the data is evidently getting into the buffer. I then tried to open the file I want to paste the info into and I get the same problem…it only pastes in what I had manually highlighted and copied before I ran the macro.

    So anyway, I thought I would let you know. I am wondering if it goes back to that Windows Buffering issue that has been mentioned before.

    John

    PS – I just thought of something to try..so I did. I ran the macro. It copied the block of data into the same file (as I mentioned above) and the copied text was still highlighted. (so if there were 4 lines of data in the file before I ran the macro, once the macro was initiated there were now eight lines of data and the last four lines that were pasted in were still highlighted.) I then thought, lets open a new file and see what gets pasted into this new file. No luck. The data that was pasted in was just like before….whatever the last thing that I manually highlighted and pasted prior to running the macro. That sounds like ME buffer.

    I then tried this. Ran the macro. Text was duplicated. Still highlighted. So I thought I would try and paste the data AGAIN into this same file. (Start with two lines. after macro have four lines.) I went to the bottom of file and did a paste (Num + key) and again……just like before. It pasted what I had manually highlighted and copied before I ran the macro).

    I am stumped!!!!!

    #9728

    Clay Martin
    Keymaster

    Hi John,
    I’m a little stumped too.

    Had another idea, what you want is to copy and paste. Seems the block ops only work in one file and don’t use the paste buffers, so, after the marking of the block use this macro to copy (you should not need to use any parms):

    void Cut(
    int Buf_Num = Parse_Int( "/B=", MParm_Str ),
    str Flags = MParm_Str
    ) trans2
    /*******************************************************************************
    Multi-Edit macro
    13-Jul-93 14:19

    Function: Copies, Moves and/or Appends text to a hidden buffer.
    Entry : int Buf_Num The buffer # (0 is the default) ( /B=# )
    str Flags The operation flags
    /M – Move text (else copy text).
    /A – Append text (else erase old buffer).
    /E – Erase buffer, perform no move or copy.
    /O=1 – The marked block will be turned turned off after the
    operation.
    /I=1 – Cut block only if cursor in block (else cut line).
    /NM=1 – Show no messages
    /NEM=1 – Will not end block marking
    /NW=1 – Windows version only. Do NOT copy block of text
    to Windows clipboard.
    /NW=2 – Copy text FROM the Windows clipboard

    Exit : None.

    And this macro to paste after your ldfiles (again you should need no parms):
    void Paste( ) trans2
    /*——————————————————————————
    Multi-Edit Macro

    Name: Paste

    Description: Copies block from buffer into current file.

    Parameters : /B=n – Buffer number
    /O=n – If non-zero then the marked block will be turned turned off
    after the operation
    /A=n – In non-zero then the cursor will be placed at the end of
    the pasted block
    /I=1 – Overwrite block only if cursor in block.
    /NM=1 – Show no messages
    /WC=1 – Use Window Clipboard
    /WC=2 – Ignore Windows Clipboard

    Thanks,
    Clay

    #9730

    JRushmeyer
    Participant

    Ok,thanks Clay. I just returned from trip to Illinois so I will play with it tomorrow.

    John

    #9731

    JRushmeyer
    Participant

    OK, Clay. We are there! I created each macro and ran them individually and they do as advertised. I ran my blocking section. Then I ran your Cut macro. Then I ran my LD section. And then I ran your Paste macro. And it worked. I am trying to incorporate all this into one macro and I think I am doing a rookie error but havent solved it yet so thought I see if you could help me out. Here is the code

    **************************************************
    VOID Big_Clay()
    {
    int han;
    TOF;
    Home;
    rm("MarkBlck");

    EOF;
    Block_End;

    RM ("Cut(int Buf_Num = Parse_Int( "/B=", MParm_Str ),str Flags = MParm_Str) trans2");
    /*………………………………..|……..*/
    Return_Str = "C:\\DATA\\Test_2.txt";
    RM("LDFILES");

    RM ("Paste() trans2");
    }

    ************************************************************************
    The error says that it expected a ")" after the " and before the backslash in /B=", MParm_Str (I tried to show it using a vertical | beneath the code line.

    Anyway, thats it. Hopefully I will solve this before you get back to me!! I really appreciate your help. (Which reminds me, I need to try and pay ME again. The web was down last week!!)

    John

    #9732

    JRushmeyer
    Participant

    Clay

    NEVERMIND!!!!

    I was right…rookie error. Forgot I didn’t need to put all the other macro code in again….just the macro name!!!!

    Thanks for your help. Now I can sleep peacefully tonight!!!

    John Rushmeyer

Viewing 12 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic.