Topic: Creating a macro to use the padline function (1 of 7), Read 37 times
Conf: Converting, Translating
From: Steven Berkowitz
Date: Monday, September 13, 2004 12:19 PM

I am a new user to VEDIT. In the convert function under edit there is an option all lines same length. I understand that there is a macro called padlines.vdm that actually performs this function. Can someone help me to convert this to a macro that I can use with a command line
invocation of vedit to just find the longest line and automatically pad with spaces to that length ?

 


Topic: Re: Creating a macro to use the padline function (2 of 7), Read 34 times
Conf: Converting, Translating
From: Christian Ziemski
Date: Monday, September 13, 2004 05:41 PM

On 13.09.2004 18:19 Steven Berkowitz wrote:

> I am a new user to VEDIT. In the convert function under edit there
> is an option all lines same length. I understand that there is a
> macro called padlines.vdm that actually performs this function.
> Can someone help me to convert this to a macro that I can use with
> a command line invocation of vedit to just find the longest line
> and automatically pad with spaces to that length ?

Steven:

All what you want is already in the original macro!

I stripped it down a bit and created PADLINES2.VDM:

http://ziemski.privat.t-online.de/vedit/macros/padlines2.vdm

That should do it.


Christian

 


Topic: Re: Creating a macro to use the padline function (3 of 7), Read 37 times
Conf: Converting, Translating
From: Fritz Heberlein
Date: Monday, September 13, 2004 06:13 PM

> I am a new user to VEDIT. In the convert function under edit there is an
> option all lines same length. I understand that there is a macro called
> padlines.vdm that actually performs this function. Can someone help me to
> convert this to a macro that I can use with a command line
> invocation of vedit to just find the longest line and automatically pad
> with spaces to that length ?


This should be straightforward: in the user.mnu that comes with Vedit,
you will find an single line macro "find longest line", which can be
the core of your macro:

//(1) find longest line

#103=#104=0
Begin_Of_File()
while (! AT_EOF) {
EOL()
if (Cur_Col>#103) { #103=Cur_Col #104=Cur_Pos }
Line(1,ERRBREAK) }
Goto_Pos(#104)

As you see, It writes the position of the longest line to #104. Now you can
simply take this value and "redefine" it as the value of the current
Column, e.g. in NReg #105.
Then, you can go sequentially through the file and pad any line that is shorter
than #105:

// (2) pad lines

#105=Cur_Col // use value of #104 als # of Cur_Col
BOF() // Goto begin of file
While(! At_EOF){ // loop:
EOL() // Goto end of line
if (Cur_Col<#105) { ins_indent(#105) } // pad lines
line(1,errbreak) //next line, break out at EOF
}


Fritz

 


Topic: Re: Creating a macro to use the padline function (4 of 7), Read 40 times
Conf: Converting, Translating
From: Christian Ziemski
Date: Tuesday, September 14, 2004 02:02 AM

Fritz:

You wrote:

> This should be straightforward: in the user.mnu that comes with Vedit,
> you will find an single line macro "find longest line", which can be
> the core of your macro:

> //(1) find longest line
>
> #103=#104=0
> Begin_Of_File()
> while (! AT_EOF) {
> EOL()
> if (Cur_Col>#103) { #103=Cur_Col #104=Cur_Pos }
> Line(1,ERRBREAK) }
> Goto_Pos(#104)
>
> As you see, It writes the position of the longest line to #104.


And the length of the longest line to #103.

So you can use #103 directly.


Christian

 


Topic: Re: Creating a macro to use the padline function (5 of 7), Read 44 times
Conf: Converting, Translating
From: Ian Binnie
Date: Tuesday, September 14, 2004 03:06 AM

On 9/14/2004 2:02:36 AM, Christian Ziemski wrote:
>Fritz:
>
>You wrote:
>
>> This should be straightforward: in the user.mnu that comes with Vedit,
>> you will find an single line macro "find longest line", which can be
>> the core of your macro:
>
>> //(1) find longest line
>>
>> #103=#104=0
>> Begin_Of_File()
>> while (! AT_EOF) {
>> EOL()
>> if (Cur_Col>#103) { #103=Cur_Col #104=Cur_Pos }
>> Line(1,ERRBREAK) }
>> Goto_Pos(#104)
>>
>> As you see, It writes the position of the longest line to #104.
>
>
>And the length of the longest
>line to #103.
>
>So you can use #103 directly.
>

Note there only works if Word_Wrap is turned off.
Config( D_DSP_WRAP, 0,LOCAL ) should be included if there is any risk of this.

>Christian

 


Topic: Re: Creating a macro to use the padline function (6 of 7), Read 47 times
Conf: Converting, Translating
From: Christian Ziemski
Date: Tuesday, September 14, 2004 06:53 AM

On 9/14/2004 3:06:36 AM, Ian Binnie wrote:
>
>Note there only works if Word_Wrap is turned off.
>Config( D_DSP_WRAP, 0,LOCAL ) should be
>included if there is any risk of this.

Thanks for the reminder!


Christian

 


Topic: Re: Creating a macro to use the padline function (7 of 7), Read 36 times
Conf: Converting, Translating
From: Steven Berkowitz
Date: Tuesday, September 14, 2004 05:29 PM

Thank you for the quick response. I will replace my padlines.vdm with the new one from Christian and give it a try.