TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: rik on August 10, 2011, 09:04:18 AM

Title: Reformat a DCL file.
Post by: rik on August 10, 2011, 09:04:18 AM
How can I automatically reformat (arrange) a DCL file?
Change this
Code: [Select]
DCL1 : dialog { label="My Dialog"; : image_button  { key        = "MyImage1" ;
width      = 25.0 ; height     =  4.0 ; color     = black ; alignment     = top ;
is_tab_stop = false ;} : button { key        = "Button1" ;
label      = "MyButton" ; width      = 25 ; height     =  2.0 ;
alignment     = top ; is_tab_stop = false ;} ok_cancel;}
to
Code: [Select]
DCL1 : dialog {
    label="My Dialog";
        : image_button  {
            key        = "MyImage1" ;
            width      = 25.0 ;
            height     =  4.0 ;
            color     = black ;
            alignment     = top ;
            is_tab_stop = false ;
        }
        : button {
            key        = "Button1" ;
            label      = "MyButton" ;
            width      = 25 ;
            height     =  2.0 ;
            alignment     = top ;
            is_tab_stop = false ;
        }
ok_cancel;
}
Thanks for reading.
Title: Re: Reformat a DCL file.
Post by: CAB on August 10, 2011, 10:13:55 AM
Try this routine.
http://www.theswamp.org/index.php?topic=10398.msg132473#msg132473

Title: Re: Reformat a DCL file.
Post by: GDF on August 10, 2011, 12:19:24 PM
http://www.theswamp.org/index.php?topic=32513.msg380119#msg380119
Title: Re: Reformat a DCL file.
Post by: rik on August 11, 2011, 02:24:56 PM
Thanks CAD and GDF,

I found no real solution for my problem.
Title: Re: Reformat a DCL file.
Post by: JohnK on August 11, 2011, 03:05:59 PM
I hate to say this but...Vim can

quick two pass search and replace.
Code: [Select]
:%s/;/;\r/g | :%s/{/{\r/g
Code: [Select]
DCL1 : dialog { label="My Dialog"; : image_button  { key        = "MyImage1" ;
width      = 25.0 ; height     =  4.0 ; color     = black ; alignment     = top ;
is_tab_stop = false ;} : button { key        = "Button1" ;
label      = "MyButton" ; width      = 25 ; height     =  2.0 ;
alignment     = top ; is_tab_stop = false ;} ok_cancel;}

goes to:

Code: [Select]
DCL1 : dialog {
    label="My Dialog";
    : image_button  {
        key        = "MyImage1" ;

        width      = 25.0 ;
        height     =  4.0 ;
        color     = black ;
        alignment     = top ;

        is_tab_stop = false ;
    } : button {
        key        = "Button1" ;

        label      = "MyButton" ;
        width      = 25 ;
        height     =  2.0 ;

        alignment     = top ;
        is_tab_stop = false ;
    } ok_cancel;
}

Title: Re: Reformat a DCL file.
Post by: alanjt on August 11, 2011, 03:11:05 PM
I hate to say this but...Vim can
nice