// // CLIPFEED.VDM C.Z. 16.11.2001 // 27.03.2003 // 03.02.2004 // // // Clipboard Feeder - to help transfering data from a list into another application. // // // // This macro steps through a list like that (or another sort of text): // // TRIAMO Italy ... // ALBRECHT USA ... // GERSHWIN Japan ... // ... ... // // It begins at cursor position, reads some text as defined in the first // dialog box and copies it to the windows clipboard. // Then a dialog window pops up and asks the user to switch to his other // application and to insert the clipboard. // Coming back to VEDIT the user just has to press ENTER (or click [next]) // to copy the next text block to the clipboard. And so on... // // To do: // If there will be a command Send_Key() in a future version of VEDIT the // macro can be made more a robot... // //------------------------------------------------------------ // // #90 Cursor Column start // #91 DI_1: Radio Button $91 number of items // #92 Start column $92 default start column // #93 End column $93 default end column // #94 // #95 Max cursor column // #96 Cursor Pos for BB $96 part of output string // #97 Cursor Pos for BE // #98 Repeat counter $98 collects text for clipboard // #99 Return Value of DI_1 // //------------------------------------------------------------ Num_Push(90,99) // save the used registers Reg_Push(90,99) #90 = Cur_Col // remember Cursor Column Save_Pos() ITOA(1, 91, LEFT+NOCR) // repeat counter ITOA(#90, 92, LEFT+NOCR) // default start column #99=#90+1 Search("|x", NOERR) // and estimate end column if (Cur_Col>#99) { #99=Cur_Col } ITOA(#99, 93, LEFT+NOCR) // default end column Restore_Pos() // cursor back to start #91=1 // default of DI_1() radio button: "words" :MAINDIALOG: #99=Dialog_Input_1(91,"`Clipboard Feeder`, ` This macro fills the Windows' clipboard step by step with`, `.l??a &number of:`, `.g()&Words: one after another`, `()Words: from the current list &column`, `()Whole &lines`, `()&Block of lines up to an really empty line (no counter)`, `()Column &range specified below`, `.g??&from column number`, `?? &to column number`, `[&Start]`,`[&Goto BoF]`,`[&Quit]`",SET+APP+CENTER,0,0) if (#99 == 2) { BoF Update goto MAINDIALOG } if (#99 != 1) { goto END } #98 = ATOI(91) // repeat counter if (#98 < 1) { goto END } while (! AT_EoF) { // repeat endless until cancel if (#91==1) { // if word wise if (#98==1) { Reg_Set(96, "word has") } else { Reg_Set(96, "words have") } Reg_Empty(98) // $98 collects the word(s) #96=Cur_Pos // remember start of whole block repeat (#98) { Block_Begin(CLEAR) Block_Begin(Cur_Pos) // mark a block from here up to Search("|x", NOERR) // the end of the word if (Error_Match) { // if there is no CR/LF in the last line EoF // goto end of file } Block_End(Cur_Pos) #97=Cur_Pos // remember end of whole block Reg_Copy_Block(98, Block_Begin, Block_End, APPEND) // copy text to $98 Reg_Set(98, " ", APPEND) // add one space as word divider Do_Visual("\NW\") // Next Word } Block_Begin(#96) // Show the word(s) as marked block Block_End(#97) Reg_Copy_Block(98, 0, 0, APPEND+CLIPBOARD) // copy $98 to Clipboard } else { if (#91==2) { // if word(s) in current column only if (#98==1) { Reg_Set(96, "word has") } else { Reg_Set(96, "words have") } Reg_Empty(98) // collects the word(s) Goto_Col(#90) // position at the same cursor column as before #96=Cur_Pos // remember start of whole block #95=0 // max Cur_Col repeat (#98) { Goto_Col(#90) // position at the same cursor column as before Block_Begin(CLEAR) Block_Begin(Cur_Pos) // from here to Search("|x", NOERR) // the end of the word if (Error_Match) { // if there is no CR/LF in the last line EoF // goto end of file } Block_End(Cur_Pos) if (Cur_Col>#95) { // determine the max cursor column #95=Cur_Col } Reg_Copy_Block(98, Block_Begin, Block_End, APPEND) if (#98>1) { // if more than one word to collect: Out_Reg(98, APPEND) Type_Newline(1) // insert newline after every entry Out_Reg(CLEAR) } Line(1, NOERR) } Block_Begin(#96) // Show the word(s) as marked block Block_Mode(COLUMN) Column_Begin(#90) if (#95<=#90) { #95=#90+1 } Column_End(#95-1) Reg_Copy_Block(98, 0, 0, APPEND+CLIPBOARD) // copy $98 to Clipboard } else { if (#91==3) { // if line wise if (#98==1) { Reg_Set(96, "line has") } else { Reg_Set(96, "lines have") } Block_Mode(CLEAR) Block_Begin(BoL_Pos) Line(#98, NOERR) Block_End(Cur_Pos) Reg_Copy_Block(98, BB, BE, CLIPBOARD) } else { if (#91==4) { // if line block up to next really empty line Reg_Set(96, "line block has") Block_Mode(CLEAR) Block_Begin(BoL_Pos) Search("|<|N", NOERR) // perhaps ignore Whitespace also??? if (EM) { EoF } Block_End(Cur_Pos) Reg_Copy_Block(98, BB, BE, CLIPBOARD) Search("|<|N", ADVANCE+NOERR) } else { if (#91==5) { // if column wise Reg_Set(96, "columnar block has") #92=ATOI(92) // begin and #93=ATOI(93)+1 // end of colmnar block Goto_Col(#92) if (Cur_Col < #92) { // if line is too short: insert spaces Ins_Char(32, COUNT, #92-Cur_Col) } Block_Begin(CLEAR) Block_Begin(Cur_Pos) Line(#98-1, NOERR) Goto_Col(#93) if (Cur_Col < #93) { // if line is too short: insert spaces Ins_Char(32, COUNT, #93-Cur_Col) } Block_End(Cur_Pos) Block_Mode(COLUMN) Column_Begin(#90) #95=Cur_Col-1 if (#95 <= #90) { #95=#90+1 } Column_End(#95) // show block Reg_Copy_Block(98, BB, BE, COLUMN+CLIPBOARD) Line(1, NOERR) // goto next line (if any) } } } } } Update // show it to the user #99=Dialog_Input_1(91,"`Action required`, `The marked |@(96) been copied to the clipboard`, `Please switch to your app and insert the clipboard.`, `Then come back ...`, `[&Next]`,`[&Main dialog]`, `[&Cancel]`",SET+APP+CENTER,0,0) if (#99 == 0 || #99 == 3) { break } if (#99 != 1) { Goto MAINDIALOG } } :END: Reg_Pop(90,99) // restore the used registers Num_Pop(90,99) return