Axaptapedia is now maintained by AgileCadence For more information please click here.

Editor scripts FormatToColumnLayout

From Axaptapedia
Jump to: navigation, search

Purpose[edit]

Allow you to select blocks of variable declarations or assignments, and format them to column layout (as suggested by msdn x++ best practices).

Description[edit]

Take the following code: <xpp> static void Example(Args _args) {

   IntrastatParameters intrastatParameters = IntrastatParameters::find();
   SalesTable salesTable;
   NumberSeq numberSeq;
   SalesLine salesLine;
   SalesFormLetter salesFormLetter;
   ;
   numberSeq = NumberSeq::newGetNumFromCode(SalesParameters::numRefSalesId().NumberSequence);
   salesTable.SalesId = numberSeq.num();
   salesTable.TransactionCode = intrastatParameters.DefaultSalePurchase;
   salesTable.Transport = intrastatParameters.TransportModeParm;
   salesTable.Port = intrastatParameters.PortParm;
   salesTable.CustAccount = "4015";

</xpp>

By selecting the block of variable declarations, then choosing Scripts -> addIns -> FormatToColumnLayout, and then the same again for the block of variable assigments will result in the following:

<xpp> static void Example(Args _args) {

   IntrastatParameters intrastatParameters = IntrastatParameters::find();
   SalesTable          salesTable;
   NumberSeq           numberSeq;
   SalesLine           salesLine;
   SalesFormLetter     salesFormLetter;
   ;
   numberSeq = NumberSeq::newGetNumFromCode(SalesParameters::numRefSalesId().NumberSequence);
   salesTable.SalesId         = numberSeq.num();
   salesTable.TransactionCode = intrastatParameters.DefaultSalePurchase;
   salesTable.Transport       = intrastatParameters.TransportModeParm;
   salesTable.Port            = intrastatParameters.PortParm;
   salesTable.CustAccount     = "4015";

</xpp>

Dynamics AX versions[edit]

Has been tested on Dynamics AX 4.0 SP2 and Dynamics AX 2009

Download[edit]

Installation[edit]

After downloading and importing the above xpo the following code needs to be pasted into a new method in the EditorScripts class:

<xpp> // <summary> /// Editor_Scripts_FormatToColumnLayout_GregP, 2009-01-24 /// Formats selected block of variable assignments or declarations into column format /// </summary> /// <param name="e">Currenty open editor</param> void addIns_FormatToColumnLayout(Editor e) {

   ;
   EditorFormat::FormatToColumnLayout(e);

} </xpp>

Used in[edit]

Editor scripts

See also[edit]

External Links[edit]

Blog post about this script