Today, at the bottom of the code editor there are 2 buttons to format the code: FORMAT TEXT and REMOVE FORMATTING.
FORMAT TEXT produces something like this:
ClearCollect( gloControlEnums, { name: "Font", values: Table( { name: "Arial", value: Font.Arial }, { name: "Courier New", value: Font.'Courier New' }, { name: "Dancing Script", value: Font.'Dancing Script' }, { name: "Georgia", value: Font.Georgia }, { name: "Great Vibes", value: Font.'Great Vibes' }, { name: "Lato", value: Font.Lato }, { name: "Lato Black", value: Font.'Lato Black' }, { name: "Lato Hairline", value: Font.'Lato Hairline' }, { name: "Lato Light", value: Font.'Lato Light' }, { name: "Open Sans", value: Font.'Open Sans' }, { name: "Open Sans Condensed", value: Font.'Open Sans Condensed' }, { name: "Patrick Hand", value: Font.'Patrick Hand' }, { name: "Segoe UI", value: Font.'Segoe UI' }, { name: "Verdana", value: Font.Verdana } ) }, { name: "FontWeight", values: Table( { name: "Bold", value: FontWeight.Bold }, { name: "Semibold", value: FontWeight.Semibold }, { name: "Normal", value: FontWeight.Normal }, { name: "Lighter", value: FontWeight.Lighter } ) } )
...while REMOVE FORMATTING produces this:
ClearCollect(gloControlEnums,{name:"Font",values:Table({name:"Arial",value:Font.Arial},{name:"Courier New",value:Font.'Courier New'},{name:"Dancing Script",value:Font.'Dancing Script'},{name:"Georgia",value:Font.Georgia},{name:"Great Vibes",value:Font.'Great Vibes'},{name:"Lato",value:Font.Lato},{name:"Lato Black",value:Font.'Lato Black'},{name:"Lato Hairline",value:Font.'Lato Hairline'},{name:"Lato Light",value:Font.'Lato Light'},{name:"Open Sans",value:Font.'Open Sans'},{name:"Open Sans Condensed",value:Font.'Open Sans Condensed'},{name:"Patrick Hand",value:Font.'Patrick Hand'},{name:"Segoe UI",value:Font.'Segoe UI'},{name:"Verdana",value:Font.Verdana})},{name:"FontWeight",values:Table({name:"Bold",value:FontWeight.Bold},{name:"Semibold",value:FontWeight.Semibold},{name:"Normal",value:FontWeight.Normal},{name:"Lighter",value:FontWeight.Lighter})})
...which looks like this in the code editor:
In fact, the code formatting that would REALLY be interesting (in terms of readability and maintenance) should be more like this:
ClearCollect( gloControlEnums, { name: "Font", values: Table( { name: "Arial", value: Font.Arial }, { name: "Courier New", value: Font.'Courier New' }, { name: "Dancing Script", value: Font.'Dancing Script' }, { name: "Georgia", value: Font.Georgia }, { name: "Great Vibes", value: Font.'Great Vibes' }, { name: "Lato", value: Font.Lato }, { name: "Lato Black", value: Font.'Lato Black' }, { name: "Lato Hairline", value: Font.'Lato Hairline' }, { name: "Lato Light", value: Font.'Lato Light' }, { name: "Open Sans", value: Font.'Open Sans' }, { name: "Open Sans Condensed", value: Font.'Open Sans Condensed' }, { name: "Patrick Hand", value: Font.'Patrick Hand' },
{ name: "Segoe UI", value: Font.'Segoe UI' }, { name: "Verdana", value: Font.Verdana } ) }, { name: "FontWeight", values: Table( { name: "Bold", value: FontWeight.Bold }, { name: "Semibold", value: FontWeight.Semibold }, { name: "Normal", value: FontWeight.Normal }, { name: "Lighter", value: FontWeight.Lighter } ) } )
Another example...
With actual FORMAT TEXT:
If( StartsWith( ThisItem.value, "ColorFade" ), ColorFade( _galPalettePropertyColorRGBA.Fill, Value( Match(/* Get fading percentage */ ThisItem.value, "-?\d+(?=(%\)))" ).FullMatch ) / 100 ), _galPalettePropertyColorRGBA.Fill )
...that could look like this with an INTERMEDIATE FORMATTING:
If( StartsWith( ThisItem.value, "ColorFade" ), ColorFade( _galPalettePropertyColorRGBA.Fill, Value( Match( ThisItem.value, "-?\d+(?=(%\)))" ).FullMatch ) / 100 ), _galPalettePropertyColorRGBA.Fill )
Some of the rules that could be applied for this INTERMEDIATE FORMATTING could be:
/* NO ! */ StartsWith(ThisItem.Value, "ColorFade" ) /* YES ! */ StartsWith( ThisItem.Value, "ColorFade" )
/* NO ! */ StartsWith(ThisItem.Value,"ColorFade"); StartsWith(ThisItem.Value, "ColorFade") /* YES ! */ StartsWith( ThisItem.Value, "ColorFade" )
Note: I really don't see the use of the REMOVE FORMATTING feature since this is already done when publishing the app. And who on earth would ever use this type for code formatting ? 🙂